Spaces:
Running
Running
Download backend/app/errors.py from shivamkr00902/data2: direct link, hf CLI and curl.
- Browser
- Download file 510 Bytes
-
https://huggingface.co/spaces/shivamkr00902/data2/resolve/main/backend/app/errors.py
- Command line
-
hf download hf://spaces/shivamkr00902/data2/backend/app/errors.py
-
curl -L -o errors.py https://huggingface.co/spaces/shivamkr00902/data2/resolve/main/backend/app/errors.py
510 Bytes
| from fastapi import HTTPException | |
| def fail(status: int, message: str, code: str = "invalid_request") -> HTTPException: | |
| return HTTPException( | |
| status, {"message": message, "type": "gateway_error", "code": code, "param": None} | |
| ) | |
| class UpstreamError(Exception): | |
| def __init__(self, status: int, code: str = "upstream_error", retry_after: int = 0): | |
| self.status = status | |
| self.code = code | |
| self.retry_after = min(max(retry_after, 0), 3600) | |
| super().__init__(code) | |