I am not able to handle customized exception for request body, 422 exception is directly rasing from fastapi
itself
I tried using:
app = FastAPI()
@app.exception_handler(RequestValidationError)
async def validation_exception_handler(request: Request, exc: RequestValidationError):
return JSONResponse(
status_code=status.HTTP_422_UNPROCESSABLE_ENTITY,
content=jsonable_encoder({"detail": exc.errors(), "body": exc.body}),
)
app.include_router(router)
app.add_exception_handler(RequestValidationError, validation_exception_handler)
But still Iam not able to handle customized exception