Spaces:
Running on Zero
Running on Zero
| from __future__ import annotations | |
| from dataclasses import dataclass | |
| from typing import Any | |
| class ApiError(Exception): | |
| code: str | |
| message: str | |
| status_code: int = 400 | |
| def __str__(self) -> str: | |
| return f"{self.code}: {self.message}" | |
| def public_error_payload(exc: ApiError) -> dict[str, Any]: | |
| return { | |
| "error": { | |
| "code": exc.code, | |
| "message": exc.message, | |
| "type": "api_error", | |
| } | |
| } | |