대시보드 에러처리 변경
parent
f7dba437cf
commit
6301186288
|
|
@ -314,7 +314,10 @@ def add_exception_handlers(app: FastAPI):
|
||||||
|
|
||||||
@app.exception_handler(DashboardException)
|
@app.exception_handler(DashboardException)
|
||||||
def dashboard_exception_handler(request: Request, exc: DashboardException) -> Response:
|
def dashboard_exception_handler(request: Request, exc: DashboardException) -> Response:
|
||||||
logger.debug(f"Handled DashboardException: {exc.__class__.__name__} - {exc.message}")
|
if exc.status_code < 500:
|
||||||
|
logger.warning(f"Handled DashboardException: {exc.__class__.__name__} - {exc.message}")
|
||||||
|
else:
|
||||||
|
logger.error(f"Handled DashboardException: {exc.__class__.__name__} - {exc.message}")
|
||||||
return JSONResponse(
|
return JSONResponse(
|
||||||
status_code=exc.status_code,
|
status_code=exc.status_code,
|
||||||
content={
|
content={
|
||||||
|
|
|
||||||
|
|
@ -130,6 +130,9 @@ async def get_session() -> AsyncGenerator[AsyncSession, None]:
|
||||||
try:
|
try:
|
||||||
yield session
|
yield session
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
from app.dashboard.exceptions import DashboardException
|
||||||
|
if isinstance(e, DashboardException):
|
||||||
|
raise e
|
||||||
import traceback
|
import traceback
|
||||||
await session.rollback()
|
await session.rollback()
|
||||||
logger.error(traceback.format_exc())
|
logger.error(traceback.format_exc())
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue