Errors
The error hierarchy and how to handle failures.
Every failure in the TypeScript SDK is thrown as DaytonaError or one of its subclasses — named to match the official Daytona SDK so existing error handling ports unchanged. HTTP failures map onto subclasses by status code; client-side failures (validation, timeouts, connection errors) use the same classes.
Hierarchy
All classes are importable from @rlp/sdk:
| Error | HTTP status | Thrown when |
|---|---|---|
DaytonaError | any / none | Base class; also thrown directly for unmapped statuses and generic failures (e.g. a sandbox landing in error). |
DaytonaValidationError | 400 | Invalid input — server-side, or client-side (missing apiUrl, negative timeout, missing snapshot/image). |
DaytonaAuthenticationError | 401 | Authentication failed, including a missing API key at client construction. |
DaytonaAuthorizationError | 403 | Request forbidden. |
DaytonaNotFoundError | 404 | Resource not found. |
DaytonaConflictError | 409 | Resource conflict — e.g. deleting a volume that is still attached. |
DaytonaRateLimitError | 429 | Rate limit exceeded. |
DaytonaNotSupportedError | 501 | Operation not supported — e.g. stop()/pause()/fork() on a non-persistent sandbox, or archive(). |
DaytonaTimeoutError | — | An HTTP request or a wait (e.g. waitUntilStarted) timed out. |
DaytonaConnectionError | — | The request never got a response — the network connection failed. |
Every instance carries:
| Property | Type | Description |
|---|---|---|
message | string | Human-readable message (from the API's error body when available). |
statusCode | number | undefined | HTTP status, when the error came from a response. |
errorCode | string | undefined | Machine-readable code from the API body, when present. |
Subclasses set name and their prototype correctly, so both instanceof checks and error.name work.
Patterns
Handle a create timeout by inspecting and cleaning up the sandbox:
Retry on rate limits:
Branch on capability — persistent-only operations throw DaytonaNotSupportedError locally:
Detect a spot-evicted sandbox: eviction pauses a persistent spot sandbox (or deletes an ephemeral one), so a non-running persistent spot sandbox can simply be started again. See spot sandboxes.