InvergeDocs
PythonAPI reference

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)
SymbolKindSummary
NexusErrorclassBase class for every Nexus SDK failure.
ConfigurationErrorclassThe SDK was configured wrongly (missing API key, bad base URL, ...).
TransportErrorclassA network-level failure: DNS, connection refused, TLS, timeout.
ApiErrorclassA non-2xx response from the Nexus API.
AuthenticationErrorclass401 — the API key is missing, malformed, or revoked.
PermissionDeniedErrorclass403 — the key is valid but not allowed to do this.
NotFoundErrorclass404 — no such resource in this environment.
ValidationErrorclass400/422 — the request body failed server-side validation.
RateLimitErrorclass429 — too many requests.
ServerErrorclass5xx — the Nexus API failed.
api_error_for()functionBuild the most specific ApiError subclass for a response.

NexusError

class

Base class for every Nexus SDK failure.

Extends Exception.

View source

ConfigurationError

class

The SDK was configured wrongly (missing API key, bad base URL, ...).

Extends NexusError, ValueError.

View source

TransportError

class

A network-level failure: DNS, connection refused, TLS, timeout.

The original exception, when there was one, is available as __cause__.

Extends NexusError.

View source

ApiError

class

A 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.

View source

ApiError

constructor
ApiError(message, *, status, code=None, details=None, method=None, path=None, body=None)

Parameters

Prop

Type

View source

AuthenticationError

class

401 — the API key is missing, malformed, or revoked.

Extends ApiError.

View source

PermissionDeniedError

class

403 — the key is valid but not allowed to do this.

Extends ApiError.

View source

NotFoundError

class

404 — no such resource in this environment.

Extends ApiError.

View source

ValidationError

class

400/422 — the request body failed server-side validation.

Extends ApiError.

View source

RateLimitError

class

429 — too many requests. retry_after is in seconds when sent.

Extends ApiError.

View source

RateLimitError

constructor
RateLimitError(*args, retry_after=None, **kwargs)

Parameters

Prop

Type

View source

ServerError

class

5xx — the Nexus API failed. Safe to retry idempotent calls.

Extends ApiError.

View source

Functions

api_error_for()

function
def api_error_for(status, payload, *, method=None, path=None, raw=None, headers=None) -> ApiError

Build the most specific ApiError subclass for a response.

Parameters

Prop

Type

Returns ApiError

View source

On this page