Skip to content

Commit 0daf392

Browse files
committed
fix logs
1 parent 19da21d commit 0daf392

1 file changed

Lines changed: 9 additions & 9 deletions

File tree

app_includes/logs_errors.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
from http import HTTPStatus
77

8-
from logs.logging import logger
8+
from config.setup_logs.logging import logger
99
from 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

0 commit comments

Comments
 (0)