SandboxError in TypeScript, SandboxError in Python - so you can catch it broadly or narrow down to a specific case.
Error hierarchy
Python renames
TimeoutError to SandboxTimeoutError so it doesn’t shadow Python’s built-in TimeoutError.Catching a specific error
Catch the typed subclass you care about and fall back toSandboxError for everything else.
Base error properties
Every SDK error extendsSandboxError and exposes:
statusCode?: number/status_code: int | None- HTTP status, if the error originated from an API responsecode?: string/code: str | None- API-provided error code, when present
Idempotent operations
kill() / kill_by_id() swallow 404 internally - it’s safe to call on a sandbox that was already deleted by another process. Every other method surfaces NotFoundError to the caller.
Retries
The SDK automatically retries transient failures onGET and DELETE requests with exponential backoff and jitter:
429 Too Many Requests5xxserver errors- Network errors (connection reset, DNS failure)
POST / PATCH requests are not retried automatically because they aren’t safely idempotent - the SDK surfaces the error so you can decide.
RateLimitError
Raised on 429 responses. Branch on code to distinguish the variant:
The error
message already includes the cap and a contact-support hint, so surfacing it directly to users is usually fine.
BuildError
Raised by Template.waitUntilReady() / wait_until_ready() when the awaited build lands on status failed.
Fields:
code- stable error prefix (image_pull_failed,step_failed,boot_failed,snapshot_failed,start_cmd_failed,ready_cmd_failed,build_failed)buildId/build_id- the build that failedtemplateId/template_id- the template idmessage- human-readable detail. The backend’serror_messagefollows a"<code>: <detail>"convention (e.g."image_too_large: image is too large for the requested disk_mib"); the SDK splits it socodeholds the prefix andmessageholds the detail. When the backend doesn’t include a prefix or message,messagefalls back to"Template build failed".