docs/examples/onboarding/fastapi/exceptions.py
raw| 1 | from litestar import Litestar, get |
| 2 | from litestar.exceptions import HTTPException |
| 3 | |
| 4 | |
| 5 | @get("/") |
| 6 | async def index() -> None: |
| 7 | response_fields = {"array": "value"} |
| 8 | raise HTTPException( |
| 9 | status_code=400, |
| 10 | detail=f"can't get that field: {response_fields.get('missing')}", |
| 11 | ) |
| 12 | |
| 13 | |
| 14 | app = Litestar(route_handlers=[index]) |