KapsoEx.Error exception (kapso_ex v0.1.0)

Copy Markdown View Source

Returned as {:error, %KapsoEx.Error{}} when a request fails.

Fields

  • :status - HTTP status code, or nil for transport errors.
  • :message - human readable message extracted from the response body.
  • :code - error code from the body when present. Meta-style errors from the WhatsApp API carry an integer code (for example 131047), Platform errors may carry a string code (for example "findings_not_enabled").
  • :body - the decoded response body.
  • :headers - response headers, a map of lowercase name to list of values.
  • :retry_after - seconds from the Retry-After header, when present. Set on 429 responses.
  • :reason - the underlying exception for transport errors (timeouts, connection refused, ...).

Summary

Types

t()

@type t() :: %KapsoEx.Error{
  __exception__: true,
  body: term(),
  code: integer() | String.t() | nil,
  headers: %{optional(String.t()) => [String.t()]},
  message: String.t(),
  reason: Exception.t() | nil,
  retry_after: non_neg_integer() | nil,
  status: non_neg_integer() | nil
}