Skip to main content
All SDK errors extend SandboxError, which extends the built-in Error. You can catch SandboxError to handle any Declaw-specific failure, or catch a specific subclass for granular control.

Error hierarchy


SandboxError

Base class for all Declaw errors.
Properties

TimeoutError

Thrown when an operation exceeds its configured timeout.

NotFoundError

Thrown when the sandbox or a requested resource does not exist (HTTP 404).

AuthenticationError

Thrown when the API key is missing or invalid (HTTP 401/403).

InvalidArgumentError

Thrown when a method receives an argument that fails validation. For example, createTransformationRule() throws this for invalid regex patterns or disallowed sandbox IDs containing special characters.

NotEnoughSpaceError

Thrown when the sandbox filesystem is full and a write fails.

CommandExitError

Thrown by CommandHandle.wait() when the process exits with a non-zero code. Contains the full stdout, stderr, and exit code.
Properties
CommandExitError is thrown only by handle.wait(). The foreground sbx.commands.run() (without background: true) returns a CommandResult with a non-zero exitCode rather than throwing. Check result.exitCode manually in foreground mode.

TemplateError

Base class for template-related errors.

BuildError

Thrown when Template.build() fails.

FileUploadError

Thrown when a file upload fails (e.g. a network error during a write operation).

GitAuthError

Thrown when git operations inside the sandbox fail due to authentication errors.

GitUpstreamError

Thrown when git operations fail due to upstream repository errors.

Catching all Declaw errors


Using error.name for discrimination

Because name is set on every subclass, you can discriminate without instanceof:

Retry patterns

Manual retry with exponential back-off

Handle non-zero exit codes in foreground mode

Cleanup on error using await using