View Source Stripe.Error (stripity_stripe v3.2.0)
A struct which represents an error which occurred during a Stripe API call.
This struct is designed to provide all the information needed to effectively log and maybe respond to an error.
It contains the following fields:
:source– this is one of:internal– the error occurred within the library. This is usually caused by an unexpected or missing parameter.:network– the error occurred while making the network request (i.e.:hackney.request/5returned an error.) In this case,:codewill always be:network_error. The:hackney_reasonfield in the:extramap contains the actual error reason received from hackney.:stripe– an error response was received from Stripe.
:code– an atom indicating the particular error. See "Error Codes" for more detail.:request_id– if:sourceis:stripe, this will contain the request ID for logging and troubleshooting. Otherwise, this field isnil.:message– a loggable message describing the error. This should not be shown to your users but is intended for logging and troubleshooting.:user_message– if Stripe has provided a user-facing message (e.g. when a card is declined), this field will contain it. Otherwise it isnil.:extra- a map which may contain some additional information about the error. See "Extra Fields" for details.
Extra Fields
The :extra field contains a map of miscellaneous information about the error which may be
useful. The fields are not present if not relevant. The possible fields are:
:card_code– when:codeis:card_error, contains one of Stripe's decline reasons.:decline_code– an optional short string provided by the bank when a card is declined.:param– for errors where a particular parameter was the cause, indicates which parameter was invalid.:charge_id– when a Charge was declined, indicates the ID of the failed Charge which was created.:http_status– for:stripeerrors, the HTTP status returned with the error.:raw_error– the raw error map received from Stripe.:hackney_reason– for:networkerrors, contains the error reason received from hackney.
Error Codes
The :code fields may be one of the following:
:api_connection_error,:api_error,:authentication_error,:card_error,:invalid_request_error,:rate_limit_error,:validation_error– as per the Stripe docs:bad_request,:unauthorized,:request_failed,:not_found,:conflict,:too_many_requests,:server_error,:unknown_error– these only occur if Stripe did not send an explicittypefor the error. They have the meaning as defined in Stripe's HTTP status code summary:network_code– used only when:sourceis:network. Indicates an error occurred while making the request.:valid_keys_failed,:required_keys_failed,:endpoint_fun_invalid_result,:invalid_endpoint– used when:sourceis:internal. SeeStripe.Requestfor details.
Summary
Types
@type card_error_code() ::
  :invalid_number
  | :invalid_expiry_month
  | :invalid_expiry_year
  | :invalid_cvc
  | :invalid_swipe_data
  | :incorrect_number
  | :expired_card
  | :incorrect_cvc
  | :incorrect_zip
  | :card_declined
  | :missing
  | :processing_error
  | :bank_account_verification_failed
  | :idempotency_key_in_use
      @type error_source() :: :internal | :network | :stripe
      @type error_status() ::
  :bad_request
  | :unauthorized
  | :request_failed
  | :not_found
  | :conflict
  | :too_many_requests
  | :server_error
  | :unknown_error
      @type stripe_error_type() ::
  :api_connection_error
  | :api_error
  | :authentication_error
  | :card_error
  | :invalid_request_error
  | :rate_limit_error
  | :validation_error
      @type t() :: %Stripe.Error{ code: error_status() | stripe_error_type() | Stripe.Request.error_code() | :network_error, extra: %{ optional(:card_code) => card_error_code(), optional(:decline_code) => String.t(), optional(:param) => String.t(), optional(:charge_id) => Stripe.id(), optional(:http_status) => 400..599, optional(:raw_error) => map(), optional(:hackney_reason) => any() }, message: String.t(), request_id: String.t() | nil, source: error_source(), user_message: String.t() | nil }