Exceptions
Every exception the SDK can raise.
from nexus.exceptions import …Every exception the SDK can raise.
All of them derive from NexusError, so except NexusError is always
enough to contain the SDK:
from nexus import NexusError
try:
nexus.push.send_to_user("u_1", title="Hi")
except NexusError as exc:
log.warning("nexus unavailable: %s", exc)| Symbol | Kind | Summary |
|---|---|---|
NexusError | class | Base class for every Nexus SDK failure. |
ConfigurationError | class | The SDK was configured wrongly (missing API key, bad base URL, ...). |
TransportError | class | A network-level failure: DNS, connection refused, TLS, timeout. |
ApiError | class | A non-2xx response from the Nexus API. |
AuthenticationError | class | 401 — the API key is missing, malformed, or revoked. |
PermissionDeniedError | class | 403 — the key is valid but not allowed to do this. |
NotFoundError | class | 404 — no such resource in this environment. |
ValidationError | class | 400/422 — the request body failed server-side validation. |
RateLimitError | class | 429 — too many requests. |
ServerError | class | 5xx — the Nexus API failed. |
api_error_for() | function | Build the most specific ApiError subclass for a response. |
NexusError
classBase class for every Nexus SDK failure.
Extends Exception.
ConfigurationError
classThe SDK was configured wrongly (missing API key, bad base URL, ...).
Extends NexusError, ValueError.
TransportError
classA network-level failure: DNS, connection refused, TLS, timeout.
The original exception, when there was one, is available as __cause__.
Extends NexusError.
ApiError
classA non-2xx response from the Nexus API.
The API answers failures with {"error": {"code", "message", "details"}};
those three fields are exposed as code, the exception message, and
details.
Extends NexusError.
ApiError
constructorApiError(message, *, status, code=None, details=None, method=None, path=None, body=None)Parameters
Prop
Type
AuthenticationError
class401 — the API key is missing, malformed, or revoked.
Extends ApiError.
PermissionDeniedError
class403 — the key is valid but not allowed to do this.
Extends ApiError.
NotFoundError
class404 — no such resource in this environment.
Extends ApiError.
ValidationError
class400/422 — the request body failed server-side validation.
Extends ApiError.
RateLimitError
class429 — too many requests. retry_after is in seconds when sent.
Extends ApiError.
RateLimitError
constructorRateLimitError(*args, retry_after=None, **kwargs)Parameters
Prop
Type
ServerError
class5xx — the Nexus API failed. Safe to retry idempotent calls.
Extends ApiError.
Functions
api_error_for()
functiondef api_error_for(status, payload, *, method=None, path=None, raw=None, headers=None) -> ApiErrorBuild the most specific ApiError subclass for a response.
Parameters
Prop
Type
Returns ApiError
