Every failure surfaced by the SDK is a or one of its subclasses. Branch on the subclass withDocumentation Index
Fetch the complete documentation index at: https://docs.photon.codes/docs/llms.txt
Use this file to discover all available pages before exploring further.
instanceof for broad handling, or switch on error.code for precise recovery.
The error hierarchy
| Subclass | Maps from gRPC |
|---|---|
AuthenticationError | UNAUTHENTICATED, PERMISSION_DENIED |
NotFoundError | NOT_FOUND |
RateLimitError | RESOURCE_EXHAUSTED |
ValidationError | INVALID_ARGUMENT, FAILED_PRECONDITION |
ConnectionError | UNAVAILABLE, DEADLINE_EXCEEDED |
WhatsAppError | Everything else |
Error fields
EveryWhatsAppError carries:
| Field | Description |
|---|---|
code | Canonical error code — one of ErrorCode. |
retryable | true when the caller can safely retry with backoff. |
grpcCode | Numeric gRPC status code (mirrors nice-grpc-common’s Status enum). |
context | Record<string, string> of extra server-provided context. |
cause | The underlying error, when one was thrown by the transport. |
Error codes
ErrorCode
Canonical error codes returned by the server.
ErrorCode
Canonical error codes returned by the server.
| Code | Value |
|---|---|
unauthenticated | "unauthenticated" |
unauthorized | "unauthorized" |
rateLimitExceeded | "rateLimitExceeded" |
notFound | "notFound" |
invalidArgument | "invalidArgument" |
preconditionFailed | "preconditionFailed" |
serviceUnavailable | "serviceUnavailable" |
timeout | "timeout" |
internalError | "internalError" |
networkError | "networkError" |
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 viaClientOptions.retry:
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 inevents.subscribe() trigger the reconnect machinery rather than throwing — see Events → Reconnection. Errors from unary calls (messages.send, media.upload, events.fetchMissed) throw.