Xero.Error exception (Xero v1.0.0)

Copy Markdown View Source

Structured error type returned by all Xero API operations.

All public functions return {:ok, result} or {:error, Xero.Error.t()}.

Error Types

:typeHTTPDescription
:unauthorized401Invalid/expired access token
:forbidden403Insufficient scope or permissions
:not_found404Resource does not exist
:unprocessable422Validation error
:rate_limited429Rate limit exceeded
:server_error5xxXero server error
:network_errorConnection/timeout failure
:config_errorInvalid library usage
:oauth_errorOAuth token endpoint failure

Summary

Types

error_type()

@type error_type() ::
  :unauthorized
  | :forbidden
  | :not_found
  | :unprocessable
  | :rate_limited
  | :server_error
  | :network_error
  | :config_error
  | :oauth_error
  | :unknown

t()

@type t() :: %Xero.Error{
  __exception__: true,
  detail: term(),
  message: String.t(),
  raw: term(),
  request_id: String.t() | nil,
  retry_after: pos_integer() | nil,
  status: pos_integer() | nil,
  type: error_type()
}

Functions

config_error(msg)

@spec config_error(String.t()) :: t()

from_response(r)

@spec from_response(map()) :: t()

network_error(reason)

@spec network_error(term()) :: t()