diff --git a/CHANGELOG.md b/CHANGELOG.md index af4d1fb..44373b6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ - IMPORTANT : Fix bug introduced with 0.6.20 (fix arguments handling) - Add *html* return type as default argument ret_type - Add *txt* return type +- Log HTTPException with statuscode 500 as critical ## 0.6.21 diff --git a/halfapi/__init__.py b/halfapi/__init__.py index 8c1ce75..9a102e8 100644 --- a/halfapi/__init__.py +++ b/halfapi/__init__.py @@ -1,5 +1,5 @@ #!/usr/bin/env python3 -__version__ = '0.6.22-rc2' +__version__ = '0.6.22-rc3' def version(): return f'HalfAPI version:{__version__}' diff --git a/halfapi/halfapi.py b/halfapi/halfapi.py index 74c627c..7b4b76d 100644 --- a/halfapi/halfapi.py +++ b/halfapi/halfapi.py @@ -92,7 +92,7 @@ class HalfAPI(Starlette): exception_handlers={ 401: UnauthorizedResponse, 404: NotFoundResponse, - 500: InternalServerErrorResponse, + 500: HalfAPI.exception, 501: NotImplementedResponse, 503: ServiceUnavailableResponse }, @@ -148,8 +148,6 @@ class HalfAPI(Starlette): starlette_app=self) ) - - @property def version(self): return __version__ @@ -157,6 +155,11 @@ class HalfAPI(Starlette): async def version_async(self, request, *args, **kwargs): return Response(self.version) + @staticmethod + async def exception(request: Request, exc: HTTPException): + logger.critical(exc, exc_info=True) + return InternalServerErrorResponse() + @property def application(self): return self