Anu.Error (Anu v0.2.1)

Copy Markdown View Source

Represents an error returned by the WhatsApp Cloud API or an internal failure.

Fields

  • :code - error code from Meta API (integer), an anu_cloud code (string, e.g. "quota_exceeded"), or an internal atom
  • :message - human-readable error message
  • :details - additional error details (map or nil)
  • :raw - the raw response body, if available

Examples

iex> %Anu.Error{code: 131_047, message: "Re-engagement message"}
%Anu.Error{code: 131_047, message: "Re-engagement message", details: nil, raw: nil}

Summary

Functions

Creates an Anu.Error from a Meta API error response body.

Types

t()

@type t() :: %Anu.Error{
  code: integer() | String.t() | atom(),
  details: map() | nil,
  message: String.t(),
  raw: map() | nil
}

Functions

from_response(raw)

@spec from_response(map()) :: t()

Creates an Anu.Error from a Meta API error response body.

Examples

iex> Anu.Error.from_response(%{"error" => %{"code" => 100, "message" => "Invalid parameter"}})
%Anu.Error{code: 100, message: "Invalid parameter", details: nil, raw: %{"error" => %{"code" => 100, "message" => "Invalid parameter"}}}