Error types
When the SDK cannot connect to the API or receives a non-success status code (4xx or 5xx), it throws a subclass ofAPIError:
Error hierarchy
HTTP status code errors
| Status Code | Error Class | Description |
|---|---|---|
| 400 | BadRequestError | Invalid request parameters |
| 401 | AuthenticationError | Invalid or missing authentication |
| 403 | PermissionDeniedError | Insufficient permissions |
| 404 | NotFoundError | Resource not found |
| 409 | ConflictError | Request conflicts with current state |
| 422 | UnprocessableEntityError | Validation error |
| 429 | RateLimitError | Rate limit exceeded |
| ≥500 | InternalServerError | Server-side error |
| N/A | APIConnectionError | Network connectivity issue |
Connection errors
Connection-related errors inherit fromAPIConnectionError:
Handling specific errors
Catch and handle different error types:Accessing error details
TheAPIError class provides detailed information:
Using catch with promises
Handle errors inline with.catch():
Retry behavior
Certain errors are automatically retried with exponential backoff:The following errors trigger automatic retries (up to 2 attempts by default):
- Connection errors (network issues)
- 408 Request Timeout
- 409 Conflict
- 429 Rate Limit
- ≥500 Internal Server Error
- Initial retry delay: 0.5 seconds
- Maximum retry delay: 8 seconds
- Jitter: Up to 25% variance
Retry headers
The SDK respects retry timing headers:retry-after-ms: Milliseconds to wait before retryretry-after: Seconds to wait or HTTP datex-should-retry: Explicit retry instruction (true/false)