Compare commits
1 Commits
main
...
feature-da
| Author | SHA1 | Date |
|---|---|---|
|
|
6301186288 |
|
|
@ -314,7 +314,10 @@ def add_exception_handlers(app: FastAPI):
|
|||
|
||||
@app.exception_handler(DashboardException)
|
||||
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(
|
||||
status_code=exc.status_code,
|
||||
content={
|
||||
|
|
|
|||
|
|
@ -130,6 +130,9 @@ async def get_session() -> AsyncGenerator[AsyncSession, None]:
|
|||
try:
|
||||
yield session
|
||||
except Exception as e:
|
||||
from app.dashboard.exceptions import DashboardException
|
||||
if isinstance(e, DashboardException):
|
||||
raise e
|
||||
import traceback
|
||||
await session.rollback()
|
||||
logger.error(traceback.format_exc())
|
||||
|
|
|
|||
Loading…
Reference in New Issue