(0.6.22rc3) [halfapi] Log HTTPException with statuscode 500 as critical

This commit is contained in:
Maxime Alves LIRMM 2022-09-02 15:38:59 +02:00 committed by Maxime Alves LIRMM@home
parent b7e678e00f
commit f0c898ba20
3 changed files with 8 additions and 4 deletions

View File

@ -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

View File

@ -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__}'

View File

@ -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