mirror of
https://github.com/grillazz/fastapi-sqlalchemy-asyncpg.git
synced 2026-01-17 11:40:39 +03:00
lint and format
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
from fastapi import Request
|
||||
from fastapi.responses import JSONResponse
|
||||
from sqlalchemy.exc import SQLAlchemyError
|
||||
|
||||
from app.exception_handlers.base import BaseExceptionHandler
|
||||
|
||||
|
||||
@@ -8,16 +9,16 @@ class SQLAlchemyExceptionHandler(BaseExceptionHandler):
|
||||
"""Handles SQLAlchemy database exceptions."""
|
||||
|
||||
@classmethod
|
||||
async def handle_exception(cls, request: Request, exc: SQLAlchemyError) -> JSONResponse:
|
||||
async def handle_exception(
|
||||
cls, request: Request, exc: SQLAlchemyError
|
||||
) -> JSONResponse:
|
||||
request_info = await cls.extract_request_info(request)
|
||||
|
||||
await cls.log_error(
|
||||
"Database error occurred",
|
||||
request_info,
|
||||
sql_error=repr(exc)
|
||||
"Database error occurred", request_info, sql_error=repr(exc)
|
||||
)
|
||||
|
||||
return JSONResponse(
|
||||
status_code=500,
|
||||
content={"message": "A database error occurred. Please try again later."}
|
||||
)
|
||||
content={"message": "A database error occurred. Please try again later."},
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user