File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 55
66from http import HTTPStatus
77
8- from logs .logging import logger
8+ from config . setup_logs .logging import logger
99from api_v1 import ValidationError
1010
1111
@@ -50,30 +50,30 @@ async def error_handler(
5050 exc : Exception ,
5151 ):
5252 """
53- Логирование всех StarletteHTTPException
53+ Логирование всех Exception
5454 """
5555 logger .exception (exc )
5656 response = dict (
5757 status = False ,
58- error_code = exc . status_code ,
59- message = exc . detail ,
58+ error_code = 500 ,
59+ message = HTTPStatus ( 500 ). phrase ,
6060 )
6161 json_response = json .dumps (response ).encode (encoding = 'utf-8' )
6262 return json_response
6363
64- @app .exception_handler (ValidationError )
64+ @app .exception_handler (StarletteHTTPException )
6565 async def validation_error_handler (
6666 request : Request ,
67- exc : ValidationError ,
67+ exc : StarletteHTTPException ,
6868 ):
6969 """
70- Логирование всех ValidationError
70+ Логирование всех StarletteHTTPException
7171 """
7272 logger .opt (exception = True ).warning (exc )
7373 response = dict (
7474 status = False ,
75- error_code = 500 ,
76- message = HTTPStatus ( 500 ). phrase ,
75+ error_code = exc . status_code ,
76+ message = exc . detail ,
7777 )
7878 json_response = json .dumps (response ).encode (encoding = 'utf-8' )
7979 return json_response
You can’t perform that action at this time.
0 commit comments