The exception struct raised/returned for every failure mode of this library: HTTP-level errors returned by the Treasury Prime API, transport failures (DNS, TLS, timeouts, connection refused), and client-side validation errors (e.g. a missing required field) caught before a request is even sent.
Every public function that talks to the network returns
{:ok, result} | {:error, t()}, and every corresponding ! variant raises
this exception (it implements the Exception behaviour).
Fields
:type- one of:api_error,:network_error,:timeout,:validation_error, or:decode_error.:message- a human readable description, suitable for logs.:status- the HTTP status code, when:typeis:api_error.:body- the raw, JSON-decoded response body (a map), when available.:request_id- reserved for forward compatibility; Treasury Prime does not currently return a request id header, but if/when it does this field will be populated automatically.
Examples
iex> {:error, error} = TreasuryPrime.Ach.create(client, %{})
iex> error.type
:api_error
iex> error.status
400
Summary
Types
@type t() :: %TreasuryPrime.Error{ __exception__: true, body: map() | nil, message: String.t(), request_id: String.t() | nil, status: pos_integer() | nil, type: type() }
@type type() ::
:api_error | :network_error | :timeout | :validation_error | :decode_error