Skip to main content
Every failure surfaced by the SDK is a or one of its subclasses. Branch on the subclass with instanceof for broad handling, or switch on error.code for precise recovery.

The error hierarchy

Error fields

Every WhatsAppError carries:

Error codes

Switch on code when you want to react to a specific failure mode rather than a whole class:

Retrying

The SDK can retry transient errors automatically. Opt in via ClientOptions.retry:
Retries only fire when error.retryable === true. Non-retryable errors (validation failures, auth issues) propagate immediately — don’t wrap them in your own retry loop.

Subscribe vs unary calls

Streaming errors in events.subscribe() trigger the reconnect machinery rather than throwing — see Events → Reconnection. Errors from unary calls (messages.send, media.upload, events.fetchMissed) throw.