(request: Request, exc: RequestValidationError)
| 65 | |
| 66 | @app.exception_handler(RequestValidationError) |
| 67 | def validation_exception_handler(request: Request, exc: RequestValidationError): |
| 68 | details = {} |
| 69 | for error in exc.errors(): |
| 70 | details[error["loc"][-1]] = error.get("msg") |
| 71 | return JSONResponse( |
| 72 | status_code=status.HTTP_422_UNPROCESSABLE_ENTITY, |
| 73 | content=jsonable_encoder({"detail": details}), |
| 74 | ) |