Exception handling enhancement
This commit is contained in:
9
main.py
9
main.py
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user