SWCError — a typed error class that carries the HTTP status code, a human-readable message, an error type string, and a retryable flag. Checking instanceof SWCError lets you distinguish SDK errors from unexpected runtime exceptions and handle them precisely.
Catching errors
Wrap any SDK call in atry/catch block and check instanceof SWCError to access the structured error details:
SWCError properties
The HTTP status code returned by the API (e.g.
401, 404, 429, 500). For network-level failures where no HTTP response was received, this may be 0.A human-readable description of what went wrong.
A stable string identifier for the error category. One of:
not_found, unauthorized, auth, validation, network, server.true when the SDK considers this error safe to retry automatically. Network errors, 5xx server errors, and rate limit responses (429) are retryable. Client errors like 404 and 401 are not.The raw API response object, when one was received. Useful for inspecting response headers or the full error body from the server.
Error types
not_found — 404
not_found — 404
The requested resource does not exist. This is not retryable — the item you’re looking for isn’t there.
unauthorized — 401
unauthorized — 401
auth — OAuth errors
auth — OAuth errors
An error occurred during the OAuth authorization flow (e.g. an invalid authorization code or a failed token exchange). This is not retryable.
validation — 400
validation — 400
The request was malformed or a required parameter was missing or invalid. Fix the input before retrying — this error is not retryable.
network — connection failures
network — connection failures
A network-level failure occurred before a response was received: DNS resolution failed, the connection timed out, or the connection was reset. The SDK retries these automatically with exponential backoff.
server — 5xx
server — 5xx
The API returned a server-side error. These are retried automatically. If all retry attempts fail, the final error is thrown.
Automatic retries
The SDK automatically retries retryable errors — network failures,5xx responses, and rate limit hits (429) — using exponential backoff. You configure retry behavior when constructing the client:
Retry-After header returned by the API and waits the specified duration before retrying — regardless of the configured retryDelay.
When all retry attempts are exhausted, the SDK throws the final
SWCError. Your catch block always receives the last error that occurred, not the first.Error type quick reference
| Type | HTTP status | Retryable |
|---|---|---|
not_found | 404 | No |
unauthorized | 401 | No |
auth | varies | No |
validation | 400 | No |
network | — | Yes |
server | 5xx | Yes |
| Rate limit | 429 | Yes |
Branching on error type
For applications that need to respond differently to different failures, branch onerror.type rather than error.statusCode — the type values are stable across SDK versions:
Next steps
Rate limits
Monitor your quota and understand how the SDK handles rate limit responses.
Client modes
Configure
maxRetries and retryDelay when constructing the client.Authentication overview
Understand token expiry and which scopes are required for each endpoint.
Pagination
Use
pageDelay to avoid rate limit errors during auto-pagination.