Errors¶
Every exception this library raises descends from PysepalError, so a single
except PysepalError catches them all.
pysepal_api.errors ¶
Error types raised by pysepal-api.
Every exception the library raises derives from a single root, PysepalError,
so a caller can except PysepalError to catch anything this library throws.
Beneath that root:
ApiError(and its status-specific subclasses) for non-2xx HTTP responses from a SEPAL service.TransportError/NoCredentialsError/MissingHostErrorfor non-HTTP problems (network, missing config).TaskError(TaskFailed/TaskCanceled/TaskTimeout) for the terminal outcomes oftasks.wait.
PysepalError ¶
Root of every exception raised by pysepal-api.
ApiError ¶
ApiError(status_code: int, *, url: str, body: Any = None)
Base for non-2xx responses from a SEPAL service.
Source code in src/pysepal_api/errors.py
30 31 32 33 34 | |
BadRequest ¶
BadRequest(status_code: int, *, url: str, body: Any = None)
Source code in src/pysepal_api/errors.py
30 31 32 33 34 | |
Unauthorized ¶
Unauthorized(
status_code: int, *, url: str, body: Any = None
)
Source code in src/pysepal_api/errors.py
30 31 32 33 34 | |
Forbidden ¶
Forbidden(status_code: int, *, url: str, body: Any = None)
Source code in src/pysepal_api/errors.py
30 31 32 33 34 | |
NotFound ¶
NotFound(status_code: int, *, url: str, body: Any = None)
Source code in src/pysepal_api/errors.py
30 31 32 33 34 | |
Conflict ¶
Conflict(status_code: int, *, url: str, body: Any = None)
Source code in src/pysepal_api/errors.py
30 31 32 33 34 | |
TooManyRequests ¶
TooManyRequests(
status_code: int, *, url: str, body: Any = None
)
429 — rate limited. Distinct so callers can back off programmatically.
Source code in src/pysepal_api/errors.py
30 31 32 33 34 | |
ServerError ¶
ServerError(
status_code: int, *, url: str, body: Any = None
)
Source code in src/pysepal_api/errors.py
30 31 32 33 34 | |
TransportError ¶
Network/send failure: DNS, connection, timeout, etc.
ResponseError ¶
A SEPAL response could not be parsed or did not match the expected shape.
Wraps malformed JSON (json.JSONDecodeError) and pydantic ValidationError
from response parsing; the underlying cause is available via __cause__.
NoCredentialsError ¶
No usable auth could be detected.
MissingHostError ¶
No SEPAL host could be detected.
InvalidPathError ¶
A user-files path is outside the sandbox home or contains .. traversal.
Subclasses ValueError too, so existing except ValueError handlers keep
working while the error is also catchable via the PysepalError root.
TaskError ¶
TaskError(message: str, *, task: Task | None = None)
Base for a non-success terminal outcome of tasks.wait.
Carries the last-observed Task as task so callers can inspect
status_description / task_info without re-fetching.
Source code in src/pysepal_api/errors.py
100 101 102 | |
TaskFailed ¶
TaskFailed(message: str, *, task: Task | None = None)
Raised by tasks.wait when a task reaches FAILED.
Source code in src/pysepal_api/errors.py
100 101 102 | |
TaskCanceled ¶
TaskCanceled(message: str, *, task: Task | None = None)
Raised by tasks.wait when a task reaches CANCELED.
Source code in src/pysepal_api/errors.py
100 101 102 | |
TaskTimeout ¶
TaskTimeout(message: str, *, task: Task | None = None)
Raised by tasks.wait when a task does not reach a terminal state in time.
Subclasses the builtin TimeoutError too, so except TimeoutError keeps
working alongside except TaskError / except PysepalError.
Source code in src/pysepal_api/errors.py
100 101 102 | |
error_for_status ¶
error_for_status(
status_code: int, *, url: str, body: Any
) -> ApiError
Map an HTTP status code to the most specific ApiError.
Source code in src/pysepal_api/errors.py
131 132 133 134 135 136 137 138 | |