-
Notifications
You must be signed in to change notification settings - Fork 131
Description
Description
The project defines a structured custom error handling system using AppError and register_exception_handlers, but the handlers are never registered with the FastAPI application.
As a result, when AppError is raised (for example, when a template is not found), FastAPI falls back to its default exception handling and returns a 500 Internal Server Error instead of the intended status code.
This hides meaningful error responses from API consumers and reduces API reliability.
Rationale
Custom exception handling logic already exists in the codebase but is not wired into the FastAPI app.
Without registering these handlers:
AppError(status_code=404)incorrectly returns 500- API consumers receive misleading responses
- The structured error handling system becomes ineffective
Registering the handlers restores the intended API behavior.
Proposed Solution
Register the custom exception handlers in the FastAPI application entrypoint.
API Entrypoint
File: main.py
from fastapi import FastAPI
from api.routes import templates, forms
+from api.errors.handlers import register_exception_handlers
app = FastAPI()
+register_exception_handlers(app)
app.include_router(templates.router)
app.include_router(forms.router)