Mercadopago.Error exception (mercadopago_sdk_elixir v0.2.1)

Copy Markdown View Source

An API error response, produced by Mercadopago.HTTP.unwrap/1.

The SDK's own functions never return this: they report every completed response as {:ok, %{status: _, response: _}}, errors included. Use it when you would rather branch on {:ok, _} / {:error, _} than on the status code.

Summary

Functions

Builds an error from a status and a decoded response body.

Types

t()

@type t() :: %Mercadopago.Error{
  __exception__: term(),
  cause: term(),
  message: String.t(),
  response: map() | list() | binary() | nil,
  status: non_neg_integer()
}

Functions

new(status, response)

@spec new(non_neg_integer(), map() | list() | binary() | nil) :: t()

Builds an error from a status and a decoded response body.

MercadoPago is inconsistent about which key carries the human-readable text, so message falls back through "message", "error" and finally a generic string naming the status. The untouched body is always kept in :response.