SDK errors
IvyError hierarchy — IvyApiError, IvyWebSocketError, IvyTimeoutError with handling patterns
This page documents the error classes the SDK throws so you can catch and respond to failures precisely — distinguishing an expired auth token from a rate limit, a missing job, a dropped WebSocket, or a timed-out wait. Reach for it when you're writing try/catch logic or an onError handler and need to know which error type carries which recovery hint (for example, IvyApiError.isRateLimited or isNotFound). Every SDK error extends IvyError, so a single catch block can handle them all; the errors are raised by the Client, Jobs, and WebSocket calls documented alongside.
SDK Errors Reference
Planned specification. @ivybiosciences/sdk is not released, and there is no package to install. This page describes the SDK's planned interface. To call the platform today, use the REST API, the ivybloom CLI, or the MCP server.
All SDK errors extend IvyError, making it easy to catch any IvyAI-specific error in a single catch block while still distinguishing between API, WebSocket, and timeout errors.
Error Hierarchy
IvyError
Base error class for all IvyAI SDK errors.
| Property | Type | Description |
|---|---|---|
message | string | Human-readable error description |
code | string? | Machine-readable error code (e.g., "AUTH_REQUIRED") |
name | string | Always "IvyError" |
Examples
IvyApiError
Error thrown when the IvyAI API returns a non-2xx response. Provides structured access to the HTTP status code and convenience getters for common error categories.
Constructor
Properties
| Property | Type | Description |
|---|---|---|
status | number | HTTP status code (400, 401, 404, 422, 429, 500, etc.) |
detail | string | Error message from the API response body |
body | unknown | Raw response body for debugging |
Convenience Getters
| Getter | Returns true when | Recommended action |
|---|---|---|
isRateLimited | HTTP 429 | Back off and retry |
isNotFound | HTTP 404 | Check resource ID |
isUnauthorized | HTTP 401 | Re-authenticate |
isForbidden | HTTP 403 | Check permissions |
isServerError | HTTP 5xx | Retry (usually transient) |
Examples
IvyWebSocketError
Error thrown when a WebSocket connection fails or closes unexpectedly.
Properties
| Property | Type | Description |
|---|---|---|
closeCode | number | The WebSocket close code |
message | string | "WebSocket closed: {reason} (code: {code})" |
Common Close Codes
| Code | Meaning | SDK Behavior |
|---|---|---|
1000 | Normal closure | No reconnect |
1001 | Server going away (deploy) | Auto-reconnect |
1006 | Abnormal closure (network) | Auto-reconnect |
1008 | Policy violation (bad token) | Auto-reconnect (new token) |
4001 | Too many connections per user | No reconnect (close other connections) |
4002 | Too many connections per job | No reconnect (close other connections) |
4003 | Authentication failed | No reconnect (re-authenticate) |
4004 | Guest feature disabled | No reconnect |
Examples
IvyTimeoutError
Error thrown when an operation exceeds its configured timeout. Most commonly occurs during submitAndWait().
Properties
| Property | Type | Description |
|---|---|---|
timeoutMs | number | The timeout value that was exceeded, in milliseconds |
message | string | "Operation timed out after {timeoutMs}ms" |
Examples
Error Handling Patterns
Catch-All SDK Errors
Comprehensive Error Handling
Harness Error Codes
The Harness Sessions API returns structured error codes with machine-readable identifiers and recovery hints. These are separate from HTTP status codes.
Error Code Ranges
| Range | Category | Description |
|---|---|---|
| 1xxx | Session | Session lifecycle errors |
| 2xxx | Storage | Database and persistence errors |
| 3xxx | Checkpoint | Checkpoint and rollback errors |
| 4xxx | Sync | Version vector and conflict errors |
| 5xxx | Tool | Tool execution errors |
| 6xxx | Auth | Authentication and authorization errors |
| 7xxx | Rate Limit | Rate limiting and quota errors |
| 8xxx | Streaming | SSE stream errors |
| 9xxx | Extension | Enterprise extension errors |
Common Error Codes
| Code | Name | HTTP | Recovery |
|---|---|---|---|
1001 | SESSION_NOT_FOUND | 404 | Create a new session |
1002 | SESSION_ARCHIVED | 409 | Unarchive or create new session |
1003 | SESSION_LOCKED | 423 | Wait for current execution to finish |
2001 | STORAGE_UNAVAILABLE | 503 | Retry after backoff |
2002 | STORAGE_WRITE_FAILED | 500 | Retry; check database connectivity |
3001 | CHECKPOINT_NOT_FOUND | 404 | List checkpoints to find valid ID |
3002 | CHECKPOINT_EXPIRED | 410 | Checkpoints beyond retention are pruned |
4001 | SYNC_CONFLICT | 409 | Re-fetch session state and retry |
4002 | SYNC_VERSION_MISMATCH | 409 | Pull latest version vector first |
5001 | TOOL_NOT_FOUND | 404 | Check tool name against /api/harness/tools |
5002 | TOOL_EXECUTION_FAILED | 502 | Retry; check tool parameters |
5003 | TOOL_TIMEOUT | 504 | Increase timeout or simplify parameters |
6001 | AUTH_REQUIRED | 401 | Provide API key or JWT |
6002 | AUTH_EXPIRED | 401 | Refresh JWT token |
6003 | INSUFFICIENT_PERMISSIONS | 403 | Check API key scopes |
7001 | RATE_LIMITED | 429 | Wait for Retry-After header duration |
7002 | QUOTA_EXCEEDED | 429 | Upgrade plan or wait for quota reset |
8001 | STREAM_INTERRUPTED | 502 | Reconnect and resume from last event |
9001 | EXTENSION_NOT_FOUND | 404 | Check enterprise extension configuration |
Handling Harness Errors
Automatic Retry (Built-in)
The SDK automatically retries transient errors (429, 500, 502, 503, 504) with exponential backoff. You only receive these errors after all retries are exhausted.
The retry formula: baseDelay * 2^attempt + random_jitter
Was this page helpful?