[lib.domain] check if an HTTPException is raised, else raise an HTTPException(500)

This commit is contained in:
Maxime Alves LIRMM 2021-06-18 10:39:05 +02:00
parent 15d69efd60
commit a14285475e
1 changed files with 6 additions and 0 deletions

View File

@ -62,6 +62,12 @@ def route_decorator(fct: FunctionType, ret_type: str = 'json') -> Coroutine:
return ORJSONResponse(fct(**fct_args))
except NotImplementedError as exc:
raise HTTPException(501) from exc
except Exception as exc:
# TODO: Write tests
if not isinstance(exc, HTTPException):
raise HTTPException(500)
raise exc
else:
raise Exception('Return type not available')