StarlingBank.Error exception (StarlingBank v1.0.0)

Copy Markdown View Source

A normalized error struct returned by every StarlingBank function on failure.

Starling's APIs return a few different error shapes depending on the failure type (OAuth errors, {"errors": [...]}, {"success": false}, plain HTTP errors, etc). This struct normalizes all of them.

Summary

Types

reason()

@type reason() ::
  :unauthorized
  | :forbidden
  | :insufficient_scope
  | :not_found
  | :bad_request
  | :rate_limited
  | :server_error
  | :network_error
  | :decode_error
  | :unknown

t()

@type t() :: %StarlingBank.Error{
  __exception__: true,
  details: term(),
  message: String.t(),
  reason: reason(),
  request_id: String.t() | nil,
  status: pos_integer() | nil
}