Spaces:
Sleeping
Sleeping
Download app/errors.py from notsn/headless_scilab: direct link, hf CLI and curl.
- Browser
- Download file 856 Bytes
-
https://huggingface.co/spaces/notsn/headless_scilab/resolve/main/app/errors.py
- Command line
-
hf download hf://spaces/notsn/headless_scilab/app/errors.py
-
curl -L -o errors.py https://huggingface.co/spaces/notsn/headless_scilab/resolve/main/app/errors.py
856 Bytes
| from __future__ import annotations | |
| from enum import Enum | |
| from typing import Any | |
| class ErrorCode(str, Enum): | |
| NETWORK = "XCOS_ERR_NETWORK" | |
| TIMEOUT = "XCOS_ERR_VALIDATION_TIMEOUT" | |
| VALIDATION_FAILED = "XCOS_ERR_VALIDATION_FAILED" | |
| CANCELLED = "XCOS_ERR_CANCELLED" | |
| UNAUTHORIZED = "XCOS_ERR_UNAUTHORIZED" | |
| BAD_REQUEST = "XCOS_ERR_BAD_REQUEST" | |
| INTERNAL = "XCOS_ERR_INTERNAL" | |
| SERVICE_UNAVAILABLE = "SERVICE_UNAVAILABLE" | |
| def error_payload( | |
| code: ErrorCode, | |
| message: str, | |
| *, | |
| correlation_id: str, | |
| details: dict[str, Any] | None = None, | |
| ) -> dict[str, Any]: | |
| payload: dict[str, Any] = { | |
| "error": { | |
| "code": code.value, | |
| "message": message, | |
| }, | |
| "correlation_id": correlation_id, | |
| } | |
| if details: | |
| payload["error"]["details"] = details | |
| return payload | |