ovok_sdk.errors

Errors the SDK raises, one class per kind of failure.

  • Stable unknown
  • Release candidate since 0.1.0-rc.4
  • Development since 0.1.0-dev.25+2ba84b0

Errors the SDK raises, one class per kind of failure.

FieldError

FieldError(
    message: str,
    path: tuple[str, ...] = (),
    code: str | None = None,
    validation: str | None = None,
)

One invalid part of a request, named by its path.

Attributes

NameTypeDescription
messagestrWhat is wrong with the value.
pathtuple[str, ...]Location of the value in the request body, such as ("name", "0").
codestr | NoneMachine-readable error code, when the API sends one.
validationstr | NoneName of the failed validation rule, when the API sends one.

OvokErrorDetails

OvokErrorDetails(
    message: str,
    status: int | None = None,
    code: str | None = None,
    type: str | None = None,
    trace_id: str | None = None,
    request_id: str | None = None,
    retry_after_ms: int | None = None,
    field_errors: tuple[FieldError, ...] = (),
)

Everything known about one failure; the fields of an OvokError.

Attributes

NameTypeDescription
messagestrHuman-readable description.
statusint | NoneHTTP status, or None when no response arrived.
codestr | NoneMachine-readable error code from the response.
typestr | NoneError type from the response.
trace_idstr | NoneServer trace ID; quote it when reporting the failure.
request_idstr | NoneServer request ID.
retry_after_msint | NoneHow long to wait before retrying, from Retry-After.
field_errorstuple[FieldError, ...]Invalid parts of the request.

OvokError

OvokError(details: OvokErrorDetails)

Bases: Exception

Every SDK failure; quote trace_id when reporting one.

Catch this class to handle any SDK error. Its attributes copy OvokErrorDetails.

Parameters

NameTypeDefaultDescription
detailsOvokErrorDetailsEverything known about the failure.

Attributes

NameTypeDescription
messageHuman-readable description.
statusHTTP status, or None when no response arrived.
codeMachine-readable error code from the response.
typeError type from the response.
trace_idServer trace ID.
request_idServer request ID.
retry_after_msHow long to wait before retrying, from Retry-After.
field_errorsInvalid parts of the request.

OvokValidationError

OvokValidationError()

Bases: OvokError

The request was malformed or failed validation (400, 422).

OvokAuthenticationError

OvokAuthenticationError()

Bases: OvokError

Credentials are missing, invalid or expired (401).

OvokPermissionError

OvokPermissionError()

Bases: OvokError

The caller is signed in but not allowed to do this (403).

OvokNotFoundError

OvokNotFoundError()

Bases: OvokError

The resource does not exist (404).

OvokConflictError

OvokConflictError()

Bases: OvokError

The request conflicts with the current state, such as a duplicate (409).

OvokRateLimitError

OvokRateLimitError()

Bases: OvokError

Too many requests (429); wait retry_after_ms before retrying.

OvokServiceError

OvokServiceError()

Bases: OvokError

The server failed or was unavailable (5xx).

OvokConnectionError

OvokConnectionError()

Bases: OvokError

No response arrived: the connection failed or timed out.

OvokConfigError

OvokConfigError()

Bases: OvokError

A client option is invalid; raised when the client is constructed.

error_for_status()

error_for_status(details: OvokErrorDetails) -> OvokError

Build the OvokError subclass that matches details.status.

Parameters

NameTypeDefaultDescription
detailsOvokErrorDetailsThe failure, with its HTTP status.

Returns

  • OvokError: OvokServiceError for 5xx, a status-specific class where one exists, else OvokError.

Last updated on

On this page