From a14285475e9d9d40248fe1b6277f9473855c0d0b Mon Sep 17 00:00:00 2001 From: Maxime Alves LIRMM Date: Fri, 18 Jun 2021 10:39:05 +0200 Subject: [PATCH] [lib.domain] check if an HTTPException is raised, else raise an HTTPException(500) --- halfapi/lib/domain.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/halfapi/lib/domain.py b/halfapi/lib/domain.py index af1aa89..134f6f1 100644 --- a/halfapi/lib/domain.py +++ b/halfapi/lib/domain.py @@ -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')