Worldpay.Error exception (Worldpay v1.0.0)

Copy Markdown View Source

Structured error returned from all Worldpay API calls.

Fields

  • :type — error classification atom
  • :status — HTTP status code (nil for non-HTTP errors)
  • :reason — atom describing the failure
  • :message — human-readable description
  • :raw — raw API response body (map or string)
  • :custom_code — Worldpay customCode field
  • :validation_errors — list of field-level validation errors from the API

Summary

Functions

Build from a network / transport error.

Build from a raw Worldpay JSON error body.

Types

error_type()

@type error_type() ::
  :http_error
  | :api_error
  | :timeout
  | :network_error
  | :circuit_open
  | :decode_error
  | :configuration_error

t()

@type t() :: %Worldpay.Error{
  __exception__: true,
  custom_code: String.t() | nil,
  message: String.t() | nil,
  raw: map() | String.t() | nil,
  reason: atom() | nil,
  status: non_neg_integer() | nil,
  type: error_type() | nil,
  validation_errors: [map()] | nil
}

Functions

from_exception(ex)

@spec from_exception(struct() | term()) :: t()

Build from a network / transport error.

from_response(status, body)

@spec from_response(pos_integer(), %{required(String.t()) => term()} | String.t()) ::
  t()

Build from a raw Worldpay JSON error body.