ExWapp.Error.Ack (ExWapp v0.1.2)

Copy Markdown View Source

Classifies the error attribute WhatsApp puts on a message acknowledgement.

A rejection code answers a question the caller cannot answer any other way: whether to send the message again, and if so whether anything has to change first. Collapsing every code to :failed throws that away, leaving callers to choose between retrying a permanently refused message and giving up on a transient one.

Only codes this library has direct evidence for are classified. Everything else is :unknown, which callers must treat as not safely retryable — an unrecognised rejection is far more likely to be a policy refusal that repeats than a blip that clears, and retrying into a refusal is how a number gets rate limited or banned.

Summary

Functions

Classifies a raw error attribute value.

True when the send may be attempted again, possibly after repairing state.

Types

category()

@type category() :: :session | :throttled | :transient | :permanent | :unknown

t()

@type t() :: %ExWapp.Error.Ack{
  category: category(),
  code: String.t(),
  detail: String.t(),
  retriable?: boolean()
}

Functions

classify(code)

@spec classify(String.t() | nil) :: t()

Classifies a raw error attribute value.

retriable? means "sending this message again may succeed", not "send it again immediately" — :throttled in particular requires a backoff.

retriable?(ack)

@spec retriable?(t()) :: boolean()

True when the send may be attempted again, possibly after repairing state.