Monzo.Error.APIError exception (monzo_client v1.0.0)

Copy Markdown View Source

Raised/returned for any non-2xx HTTP response from the Monzo API.

Carries the HTTP status, the parsed error body (if any), and the originating request id for support tickets.

Summary

Functions

True for 403 permission errors.

True for 401 responses where the access token is invalid or expired.

True when the client is being rate limited (429).

True when the error represents a transient condition safe to retry for idempotent requests.

True for 5xx errors, generally safe to retry.

Types

t()

@type t() :: %Monzo.Error.APIError{
  __exception__: true,
  code: String.t() | nil,
  message: String.t() | nil,
  method: String.t(),
  params: %{optional(String.t()) => String.t()} | nil,
  path: String.t(),
  request_id: String.t() | nil,
  status: pos_integer()
}

Functions

forbidden?(api_error)

@spec forbidden?(t()) :: boolean()

True for 403 permission errors.

invalid_token?(api_error)

@spec invalid_token?(t()) :: boolean()

True for 401 responses where the access token is invalid or expired.

rate_limited?(api_error)

@spec rate_limited?(t()) :: boolean()

True when the client is being rate limited (429).

retryable?(error)

@spec retryable?(t()) :: boolean()

True when the error represents a transient condition safe to retry for idempotent requests.

server_error?(api_error)

@spec server_error?(t()) :: boolean()

True for 5xx errors, generally safe to retry.