mirror of
https://github.com/a-mayb3/Kanban_clone_backend.git
synced 2026-03-21 10:05:38 +01:00
Added general exception handler
This commit is contained in:
parent
c7ab0f00c2
commit
6285ebbd16
1 changed files with 19 additions and 1 deletions
20
main.py
20
main.py
|
|
@ -104,4 +104,22 @@ async def validation_exception_handler(request, exc):
|
||||||
"details": exc.errors()
|
"details": exc.errors()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@app.exception_handler(Exception)
|
||||||
|
async def general_exception_handler(request, exc):
|
||||||
|
"""Handle all other exceptions"""
|
||||||
|
|
||||||
|
logger = global_logger
|
||||||
|
logger.error(f"Unexpected error: {exc}")
|
||||||
|
|
||||||
|
return JSONResponse(
|
||||||
|
status_code=500,
|
||||||
|
content={
|
||||||
|
"error": {
|
||||||
|
"message": "An unexpected error occurred.",
|
||||||
|
"type": "internal_server_error",
|
||||||
|
"details": str(exc)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)
|
||||||
Loading…
Add table
Add a link
Reference in a new issue