Aurinko.Error exception (Aurinko v0.2.1)

Copy Markdown View Source

Structured error types returned by Aurinko API calls.

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

Summary

Functions

Build a parameter validation error.

Build a network/transport-level error.

Types

error_type()

@type error_type() ::
  :auth_error
  | :not_found
  | :rate_limited
  | :server_error
  | :network_error
  | :timeout
  | :invalid_params
  | :config_error
  | :unknown

t()

@type t() :: %Aurinko.Error{
  __exception__: true,
  body: map() | String.t() | nil,
  message: String.t(),
  request_id: String.t() | nil,
  status: integer() | nil,
  type: error_type()
}

Functions

from_response(status, body, request_id \\ nil)

@spec from_response(integer(), map() | String.t(), String.t() | nil) :: t()

Build an Aurinko.Error from an HTTP response.

invalid_params(msg)

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

Build a parameter validation error.

network_error(msg)

@spec network_error(Exception.t() | String.t()) :: t()

Build a network/transport-level error.