Download errors.py from modventures/floor-visualizer-gpu: direct link, hf CLI and curl.
- Browser
- Download file 1.02 kB
-
https://huggingface.co/spaces/modventures/floor-visualizer-gpu/resolve/main/errors.py
- Command line
-
hf download hf://spaces/modventures/floor-visualizer-gpu/errors.py
-
curl -L -o errors.py https://huggingface.co/spaces/modventures/floor-visualizer-gpu/resolve/main/errors.py
1.02 kB
| """Reusable HTTP error helpers.""" | |
| from fastapi import HTTPException | |
| def bad_request(detail: str, cause: Exception | None = None) -> HTTPException: | |
| exc = HTTPException(status_code=400, detail=detail) | |
| if cause is not None: | |
| raise exc from cause | |
| raise exc | |
| def not_found(detail: str = "Not found.") -> HTTPException: | |
| raise HTTPException(status_code=404, detail=detail) | |
| def conflict(detail: str) -> HTTPException: | |
| raise HTTPException(status_code=409, detail=detail) | |
| def server_error(detail: str) -> HTTPException: | |
| raise HTTPException(status_code=500, detail=detail) | |
| def service_unavailable(detail: str, cause: Exception | None = None) -> HTTPException: | |
| exc = HTTPException(status_code=503, detail=detail) | |
| if cause is not None: | |
| raise exc from cause | |
| raise exc | |
| def bad_gateway(detail: str, cause: Exception | None = None) -> HTTPException: | |
| exc = HTTPException(status_code=502, detail=detail) | |
| if cause is not None: | |
| raise exc from cause | |
| raise exc | |