Wise.Error exception (Wise v1.0.0)

Copy Markdown View Source

Structured error returned from the Wise Platform API.

All API errors are returned as {:error, %Wise.Error{}} tuples. Network errors are returned as {:error, %Wise.Error{type: :network}}.

Fields

  • type - :api, :network, :circuit_open, :invalid_signature, :rate_limited
  • status_code - HTTP status code (nil for network errors)
  • code - Wise machine-readable error code e.g. "SCA_REQUIRED"
  • message - Human-readable description
  • errors - Per-field validation errors (populated on 422)
  • request_id - X-Request-Id header value for Wise support

Example

case Wise.Transfers.fund(client, profile_id, transfer_id) do
  {:ok, result} -> result
  {:error, %Wise.Error{code: "SCA_REQUIRED"}} -> redirect_to_sca()
  {:error, %Wise.Error{status_code: 429}} -> handle_rate_limit()
  {:error, %Wise.Error{type: :network}} -> handle_network_error()
end

Summary

Functions

Returns true if the circuit breaker rejected the request.

Extracts per-field validation errors from a 422 response.

Returns true if this is a network-level error.

Returns true if this is a 404 Not Found error.

Returns true if this is a 429 rate limit error.

Returns true if SCA (Strong Customer Authentication) is required.

Returns true if this is a 5xx server error.

Returns true if this is a 401 Unauthorized error.

Types

error_type()

@type error_type() ::
  :api | :network | :circuit_open | :invalid_signature | :rate_limited

field_error()

@type field_error() :: %{field: String.t(), code: String.t(), message: String.t()}

t()

@type t() :: %Wise.Error{
  __exception__: true,
  code: String.t() | nil,
  errors: [field_error()],
  message: String.t() | nil,
  request_id: String.t() | nil,
  status_code: non_neg_integer() | nil,
  type: error_type()
}

Functions

circuit_open?(arg1)

@spec circuit_open?(t()) :: boolean()

Returns true if the circuit breaker rejected the request.

field_errors(error)

@spec field_errors(t()) :: [field_error()]

Extracts per-field validation errors from a 422 response.

network_error?(arg1)

@spec network_error?(t()) :: boolean()

Returns true if this is a network-level error.

not_found?(arg1)

@spec not_found?(t()) :: boolean()

Returns true if this is a 404 Not Found error.

rate_limited?(arg1)

@spec rate_limited?(t()) :: boolean()

Returns true if this is a 429 rate limit error.

sca_required?(arg1)

@spec sca_required?(t()) :: boolean()

Returns true if SCA (Strong Customer Authentication) is required.

server_error?(arg1)

@spec server_error?(t()) :: boolean()

Returns true if this is a 5xx server error.

unauthorized?(arg1)

@spec unauthorized?(t()) :: boolean()

Returns true if this is a 401 Unauthorized error.