The structured exception raised/returned by every Ramp operation.
Every failure mode -- transport failures, HTTP error responses, deferred-task
failures, webhook signature failures, timeouts -- is normalized into this one
exception type so callers only need to pattern-match on :type instead of
juggling several error shapes.
Fields
:type- one oftype/0, classifying the failure.:message- a human-readable description.:status- the HTTP status code, if any.:trace_id- the value of thex-trace-idresponse header, if present. Include this when contacting Ramp support.:retry_after- seconds to wait before retrying, parsed from a429 Too Many Requestsresponse, if any.:body- the raw response body, if any, for debugging.
Examples
case Ramp.Cards.get(client, "nonexistent") do
{:ok, card} ->
card
{:error, %Ramp.Error{} = error} ->
if Ramp.Error.not_found?(error) do
:not_found
else
raise error
end
end
Summary
Functions
True if error represents an authentication (401) failure.
True if error represents an authorization (403) failure.
Builds a configuration/validation error raised before any request is sent.
Builds a JSON decode error.
Builds an error for a deferred task that finished with status ERROR.
Builds a Ramp.Error from an HTTP response's status, body, and headers.
Builds a network-layer error (connection refused, DNS failure, etc.).
True if error represents an HTTP 404 / not-found condition.
True if error represents a 429 Too Many Requests response.
True if the underlying condition is generally safe to retry.
Builds a client-side timeout error (deferred task or request timeout).
True if error represents a request validation (400) failure.
Builds a webhook signature verification error.
Types
@type t() :: %Ramp.Error{ __exception__: true, body: binary() | map() | nil, message: String.t(), retry_after: non_neg_integer() | nil, status: pos_integer() | nil, trace_id: String.t() | nil, type: type() }
@type type() ::
:authentication_error
| :authorization_error
| :not_found
| :validation_error
| :rate_limit_error
| :server_error
| :timeout_error
| :network_error
| :deferred_task_error
| :configuration_error
| :webhook_verification_error
| :decode_error
| :unknown_error
Functions
True if error represents an authentication (401) failure.
True if error represents an authorization (403) failure.
Builds a configuration/validation error raised before any request is sent.
Builds a JSON decode error.
Builds an error for a deferred task that finished with status ERROR.
@spec from_response(pos_integer(), binary(), String.t() | nil) :: t()
Builds a Ramp.Error from an HTTP response's status, body, and headers.
Builds a network-layer error (connection refused, DNS failure, etc.).
True if error represents an HTTP 404 / not-found condition.
True if error represents a 429 Too Many Requests response.
True if the underlying condition is generally safe to retry.
Note: Ramp.HTTP already retries these automatically up to
:max_retries times, so you normally never need this outside of your own
custom retry logic (e.g. around Ramp.Poller.poll/3).
Builds a client-side timeout error (deferred task or request timeout).
True if error represents a request validation (400) failure.
Builds a webhook signature verification error.