mirror of
https://github.com/grillazz/fastapi-sqlalchemy-asyncpg.git
synced 2025-11-30 13:20:40 +03:00
add excpetion_handlers module
This commit is contained in:
11
app/exception_handlers/registry.py
Normal file
11
app/exception_handlers/registry.py
Normal file
@@ -0,0 +1,11 @@
|
||||
from fastapi import FastAPI
|
||||
from sqlalchemy.exc import SQLAlchemyError
|
||||
from fastapi.exceptions import ResponseValidationError
|
||||
|
||||
from app.exception_handlers.database import SQLAlchemyExceptionHandler
|
||||
from app.exception_handlers.validation import ResponseValidationExceptionHandler
|
||||
|
||||
def register_exception_handlers(app: FastAPI) -> None:
|
||||
"""Register all exception handlers with the FastAPI app."""
|
||||
app.add_exception_handler(SQLAlchemyError, SQLAlchemyExceptionHandler.handle_exception)
|
||||
app.add_exception_handler(ResponseValidationError, ResponseValidationExceptionHandler.handle_exception)
|
||||
Reference in New Issue
Block a user