Skip to content

Instantly share code, notes, and snippets.

@Montgoner
Created February 19, 2021 17:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Montgoner/d64d81bc4c8b301f7eb4ef8b85d73184 to your computer and use it in GitHub Desktop.
Save Montgoner/d64d81bc4c8b301f7eb4ef8b85d73184 to your computer and use it in GitHub Desktop.
async def request_validation_exception_handler(request: Request, exc: RequestValidationError) -> JSONResponse:
return JSONResponse(
status_code=HTTP_422_UNPROCESSABLE_ENTITY,
content={
"error_name": exc.__class__.__name__,
"message": jsonable_encoder(exc.errors()),
},
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment