pre-commit-ci-lite[bot]
4 months ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with
3 additions and
1 deletions
-
docs_src/handling_errors/tutorial001_py310.py
|
|
|
@ -4,6 +4,7 @@ from fastapi.responses import JSONResponse |
|
|
|
|
|
|
|
app = FastAPI() |
|
|
|
|
|
|
|
|
|
|
|
@app.exception_handler(RequestValidationError) |
|
|
|
async def validation_exception_handler(request: Request, exc: RequestValidationError): |
|
|
|
""" |
|
|
|
@ -16,10 +17,11 @@ async def validation_exception_handler(request: Request, exc: RequestValidationE |
|
|
|
"message": "Erro de validação detectado pela Alantec", |
|
|
|
"details": exc.errors(), |
|
|
|
"status": "error", |
|
|
|
"code": 422 |
|
|
|
"code": 422, |
|
|
|
}, |
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
@app.get("/items/{item_id}") |
|
|
|
async def read_item(item_id: int): |
|
|
|
return {"item_id": item_id} |
|
|
|
|