mirror of https://github.com/tiangolo/fastapi.git
📝 Update docs source example
This commit is contained in:
parent
a83795f746
commit
0eec10b63a
|
|
@ -12,8 +12,11 @@ async def http_exception_handler(request, exc):
|
|||
|
||||
|
||||
@app.exception_handler(RequestValidationError)
|
||||
async def validation_exception_handler(request, exc):
|
||||
return PlainTextResponse(str(exc), status_code=400)
|
||||
async def validation_exception_handler(request, exc: RequestValidationError):
|
||||
message = "Validation errors:"
|
||||
for error in exc.errors():
|
||||
message += f"\nField: {error['loc']}, Error: {error['msg']}"
|
||||
return PlainTextResponse(message, status_code=400)
|
||||
|
||||
|
||||
@app.get("/items/{item_id}")
|
||||
|
|
|
|||
Loading…
Reference in New Issue