Exception handling enhancement

This commit is contained in:
2025-09-23 22:42:26 +02:00
parent b1a76cdb57
commit 98285aa8aa
35 changed files with 3283 additions and 1743 deletions

View File

@@ -11,6 +11,8 @@ from app.api.main import api_router
from app.core.config import settings
from app.core.database import get_db
from app.core.lifespan import lifespan
from app.exceptions.handler import setup_exception_handlers
from app.exceptions import ServiceUnavailableException
logger = logging.getLogger(__name__)
@@ -22,6 +24,9 @@ app = FastAPI(
lifespan=lifespan,
)
# Setup custom exception handlers (unified approach)
setup_exception_handlers(app)
# Add CORS middleware
app.add_middleware(
CORSMiddleware,
@@ -72,9 +77,7 @@ def health_check(db: Session = Depends(get_db)):
}
except Exception as e:
logger.error(f"Health check failed: {e}")
raise HTTPException(status_code=503, detail="Service unhealthy")
# Add this temporary endpoint to your router:
raise ServiceUnavailableException("Service unhealthy")
# Documentation redirect endpoints