Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion backend/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,11 +98,22 @@ async def dispatch(self, request: Request, call_next):
@app.exception_handler(RequestValidationError)
async def validation_exception_handler(request: Request, exc: RequestValidationError):
"""Handle validation errors with clear messages."""
# Convert errors to JSON-serializable format
errors = []
for err in exc.errors():
error_dict = {
"type": err.get("type"),
"loc": err.get("loc"),
"msg": err.get("msg"),
"input": str(err.get("input")) if err.get("input") is not None else None,
}
errors.append(error_dict)

return JSONResponse(
status_code=422,
content={
"detail": "Validation error",
"errors": exc.errors()
"errors": errors
}
)

Expand Down
Loading