Download core/errors.py from tmepass000/matter-os: direct link, hf CLI and curl.
- Browser
- Download file 1.16 kB
-
https://huggingface.co/tmepass000/matter-os/resolve/main/core/errors.py
- Command line
-
hf download hf://tmepass000/matter-os/core/errors.py
-
curl -L -o errors.py https://huggingface.co/tmepass000/matter-os/resolve/main/core/errors.py
1.16 kB
| """Machine-readable error taxonomy (section 14).""" | |
| from __future__ import annotations | |
| from enum import Enum | |
| from typing import Any | |
| class ErrorCode(str, Enum): | |
| INVALID_INPUT = "INVALID_INPUT" | |
| UNSUPPORTED_METHOD = "UNSUPPORTED_METHOD" | |
| RESOURCE_LIMIT = "RESOURCE_LIMIT" | |
| TIMEOUT = "TIMEOUT" | |
| SOLVER_FAILURE = "SOLVER_FAILURE" | |
| NON_CONVERGENCE = "NON_CONVERGENCE" | |
| NUMERICAL_WARNING = "NUMERICAL_WARNING" | |
| DATA_SOURCE_UNAVAILABLE = "DATA_SOURCE_UNAVAILABLE" | |
| CHECKSUM_MISMATCH = "CHECKSUM_MISMATCH" | |
| CANCELLED = "CANCELLED" | |
| UNKNOWN = "UNKNOWN" | |
| class MatterOSError(Exception): | |
| """Base error carrying a taxonomy code and structured details.""" | |
| def __init__(self, code: ErrorCode, message: str, **details: Any): | |
| super().__init__(f"{code.value}: {message}") | |
| self.code = code | |
| self.message = message | |
| self.details = details | |
| def to_dict(self) -> dict[str, Any]: | |
| return {"error": self.code.value, "message": self.message, "details": self.details} | |
| def invalid(message: str, **details: Any) -> MatterOSError: | |
| return MatterOSError(ErrorCode.INVALID_INPUT, message, **details) | |