# Error handling

> Handle SupportChatError, inspect error codes, and retry recoverable failures.

Source: https://docs.useclad.ai/error-handling

---

Async methods reject with a `SupportChatError`, exposed on the global as
`SupportChat.Error`:

```js
try {
  await chat.sendMessage({ conversationId, text });
} catch (err) {
  if (err instanceof SupportChat.Error) {
    console.error(err.code, err.message, err.requestId);
    if (err.recoverable) {
      // safe to retry (often after a short backoff)
    }
  }
}
```

| Field | Description |
|---|---|
| `code` | Machine‑readable error code (below). |
| `message` | Human‑readable description. |
| `reason` | Optional finer‑grained reason. |
| `requestId` | Correlation id — include it in support requests. |
| `recoverable` | Whether a retry may succeed. |

**Codes:** `not_ready`, `not_booted`, `auth_required`, `auth_expired`,
`invalid_token`, `invalid_origin`, `widget_disabled`, `rate_limited`,
`network_error`, `conversation_not_found`, `message_invalid`,
`message_send_failed`, `attachment_too_large`, `unsupported_file_type`,
`form_not_found`, `article_not_found`, `validation_error`, `internal_error`.
