Structured error type for all TruelayerClient operations.
Every public API function returns {:ok, result} or {:error, %TruelayerClient.Error{}}.
Fields
:type- machine-readable error category atom:status- HTTP status code (nil for non-HTTP errors):trace_id-Tl-Trace-Idheader value for support:should_retry- whether TrueLayer indicatedTl-Should-Retry: true:title- RFC 7807 error title:detail- RFC 7807 error detail:errors- per-field validation errors (400 responses):reason- underlying reason for non-API errors
Examples
case TruelayerClient.Payments.get_payment(client, id) do
{:ok, payment} -> payment
{:error, %TruelayerClient.Error{type: :not_found}} -> nil
{:error, %TruelayerClient.Error{trace_id: tid} = err} ->
Logger.error("TrueLayer error trace=#{tid}: #{Exception.message(err)}")
end
Summary
Functions
Returns true for 409 Conflict errors.
Build an Error from an API response.
Build a network/transport error.
Returns true for 404 Not Found errors.
Returns true for 429 Rate Limited errors.
Returns true when the error is safe to retry.
Returns true for 5xx Server errors.
Build a signing-not-configured error.
Returns true for 401 Unauthorized errors.
Types
@type error_type() ::
:api_error
| :auth_error
| :validation_error
| :not_found
| :unauthorized
| :forbidden
| :conflict
| :rate_limited
| :server_error
| :signing_required
| :replay_attack
| :signature_invalid
| :network_error
| :decode_error
| :timeout
| :unknown
@type t() :: %TruelayerClient.Error{ __exception__: true, detail: String.t() | nil, errors: [map()] | nil, reason: term(), should_retry: boolean(), status: non_neg_integer() | nil, title: String.t() | nil, trace_id: String.t() | nil, type: error_type() }
Functions
Returns true for 409 Conflict errors.
@spec from_response(map(), map(), non_neg_integer()) :: t()
Build an Error from an API response.
Build a network/transport error.
Returns true for 404 Not Found errors.
Returns true for 429 Rate Limited errors.
Returns true when the error is safe to retry.
Returns true for 5xx Server errors.
@spec signing_required() :: t()
Build a signing-not-configured error.
Returns true for 401 Unauthorized errors.