diff --git a/src/main.py b/src/main.py index 6cf14ed..424acc5 100644 --- a/src/main.py +++ b/src/main.py @@ -7,8 +7,6 @@ from fastapi.openapi.docs import get_redoc_html, get_swagger_ui_html from fastapi.responses import HTMLResponse from fastapi.security import HTTPBasic, HTTPBasicCredentials from starlette.middleware.cors import CORSMiddleware -from starlette.exceptions import HTTPException -from fastapi.exceptions import RequestValidationError from src.application.domain.exceptions import ApplicationException, UnauthorizedException from src.infrastructure.cache import create_redis_client from src.infrastructure.vault import JwtKeyStore, start_jwt_keys_scheduler @@ -17,9 +15,7 @@ from src.infrastructure.logger import logger from src.infrastructure.config import settings from src.presentation.handlers import ( application_exception_handler, - http_exception_handler, unhandled_exception_handler, - validation_exception_handler, ) from src.presentation.middleware import TraceIDMiddleware, SecurityHeadersMiddleware from src.presentation.routing import me_router @@ -84,8 +80,6 @@ app: FastAPI = FastAPI( }, ) -app.add_exception_handler(RequestValidationError, validation_exception_handler) -app.add_exception_handler(HTTPException, http_exception_handler) app.add_exception_handler(ApplicationException, application_exception_handler) app.add_exception_handler(Exception, unhandled_exception_handler) diff --git a/src/presentation/handlers/__init__.py b/src/presentation/handlers/__init__.py index e9ca9c5..d6a4f32 100644 --- a/src/presentation/handlers/__init__.py +++ b/src/presentation/handlers/__init__.py @@ -1,4 +1,2 @@ from src.presentation.handlers.unhandled_handler import unhandled_exception_handler from src.presentation.handlers.application_handler import application_exception_handler -from src.presentation.handlers.http_exception_handler import http_exception_handler -from src.presentation.handlers.validation_handler import validation_exception_handler diff --git a/src/presentation/handlers/http_exception_handler.py b/src/presentation/handlers/http_exception_handler.py deleted file mode 100644 index 84510d2..0000000 --- a/src/presentation/handlers/http_exception_handler.py +++ /dev/null @@ -1,11 +0,0 @@ -from fastapi import Request -from fastapi.responses import ORJSONResponse -from starlette.exceptions import HTTPException - - -async def http_exception_handler(_request: Request, exc: HTTPException) -> ORJSONResponse: - return ORJSONResponse( - status_code=exc.status_code, - content={'detail': exc.detail}, - headers=dict(exc.headers) if exc.headers else None, - ) diff --git a/src/presentation/handlers/validation_handler.py b/src/presentation/handlers/validation_handler.py deleted file mode 100644 index 155ac5d..0000000 --- a/src/presentation/handlers/validation_handler.py +++ /dev/null @@ -1,10 +0,0 @@ -from fastapi import Request -from fastapi.exceptions import RequestValidationError -from fastapi.responses import ORJSONResponse - - -async def validation_exception_handler(_request: Request, exc: RequestValidationError) -> ORJSONResponse: - return ORJSONResponse( - status_code=422, - content={'detail': exc.errors()}, - )