feat: add custom exceptions

This commit is contained in:
2026-05-09 16:25:31 +03:00
parent bedce9e910
commit 9d56b7f6f5
17 changed files with 214 additions and 13 deletions

View File

@@ -0,0 +1,15 @@
from fastapi import Request
from fastapi.responses import ORJSONResponse
from src.application.domain.exceptions import ApplicationException
async def application_exception_handler(_request: Request, exc: ApplicationException) -> ORJSONResponse:
detail = exc.message
if 500 <= exc.status_code:
detail = 'Internal Server Error'
return ORJSONResponse(
status_code=exc.status_code,
content={'detail': detail},
headers=dict(exc.headers) if exc.headers else None,
)