Open david-shiko opened 2 years ago
I don't understand either. It didn't come across as obvious to me that we had to use a context manager for this case. We even only have 'pass' in the exit( ) method.
The use of with
is more beneficial when dealing with resources that need to be properly managed (like files or network connections), in this case, for simplicity, it would be better to remove it.
def handle_result(result: ServiceResult):
if not result.success:
logger.error(f"{result.value} | caller={caller_info()}")
raise result.value
return result.value```
https://github.com/visini/abstracting-fastapi-services/blob/adacaba43609a0f46d1baf315d0288ae1a6c3d33/app/utils/service_result.py#L41