Noizu.WhatsApp.Error exception (Noizu.WhatsApp v0.1.0)

Copy Markdown View Source

Structured error returned by every failing call as {:error, %Noizu.WhatsApp.Error{}}.

Returned, never raised in the normal flow (it is a defexception so pagination streams can raise it mid-enumeration).

:tag:reasonWhen
:apiGraph error code (integer, e.g. 131047)non-2xx with the Graph error envelope
:rate_limited:rate_limited429 still returned after the bounded retry gave up
:http:http_errornon-2xx without a Graph envelope
:transportthe transport exceptionconnection refused, timeout, …
:configan atom (:missing_token, …)missing token / phone number id / WABA id
:validationan atom (e.g. :invalid_phone)client-side validation
  • :kind — semantic error class. Graph code 131047 (re-engagement message sent outside the 24h customer-service window) maps to :window_closed; use send_template/4 to restart the window.
  • :subcode — the Graph error_subcode when present.
  • :body — the decoded Graph error object.
  • :summary — the Graph message string. Message text never contains a full phone number (Noizu.WhatsApp.Phone.mask/1) or the access token.

Summary

Functions

Missing configuration. subject is masked via Phone.mask/1 when numeric.

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

Graph error code -> semantic kind.

Wraps a transport-level failure.

Client-side validation failure. Phone-like values are masked.

Types

kind()

@type kind() :: :window_closed | nil

t()

@type t() :: %Noizu.WhatsApp.Error{
  __exception__: term(),
  body: term(),
  code: integer() | nil,
  kind: kind(),
  message: String.t(),
  reason: term(),
  status: pos_integer() | nil,
  subcode: integer() | nil,
  summary: String.t() | nil,
  tag: :api | :rate_limited | :http | :transport | :config | :validation | nil
}

Functions

config(reason, message)

@spec config(atom(), String.t()) :: t()

Missing configuration. subject is masked via Phone.mask/1 when numeric.

from_response(status, body)

@spec from_response(pos_integer(), term()) :: t()

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

kind_for(arg1)

@spec kind_for(term()) :: kind()

Graph error code -> semantic kind.

transport(reason)

@spec transport(term()) :: t()

Wraps a transport-level failure.

validation(reason, message)

@spec validation(atom(), String.t()) :: t()

Client-side validation failure. Phone-like values are masked.