SandboxException, which inherits from the built-in Exception. You can catch the base class to handle any Declaw error, or catch specific subclasses for granular handling.
Exception hierarchy
SandboxException
Base class for all Declaw exceptions.
Branch on
.code, not on the message. Messages are prose and change between
releases; codes are contract. It matters most where one status means several
unrelated things — a 409 from sandbox creation is either
idempotency_in_progress (the original create is still running) or
template_not_ready (the template needs a rebuild), and only the first is worth
retrying. Every exception carries .code; it is "" when the response had none,
so you can compare it without a getattr guard.TimeoutException
Raised when an operation exceeds its configured timeout.
sandbox_id from SandboxException.
NotFoundException
Raised when the sandbox or a requested resource does not exist (HTTP 404).
AuthenticationException
Raised when the API key is missing or invalid (HTTP 401/403).
InvalidArgumentException
Raised when a method receives an argument that fails validation.
NotEnoughSpaceException
Raised when the sandbox filesystem is full and a write operation fails.
CommandExitException
Raised when a command exits with a non-zero exit code. Contains the full stdout, stderr, and exit code.
CommandExitException is only raised by CommandHandle.wait(). The main
sbx.commands.run() method returns a CommandResult with a non-zero
exit_code rather than raising — you must check result.exit_code yourself
unless you use a background handle.TemplateException
Base class for template-related errors.
BuildException
Raised when a Template.build() call fails.
FileUploadException
Raised when uploading a file to the sandbox fails (e.g. network error during multipart upload).
GitAuthException
Raised when git operations inside the sandbox fail due to authentication errors.
GitUpstreamException
Raised when git operations fail due to upstream repository errors.
InsufficientBalanceException
Raised when the account has insufficient balance to start or continue a
sandbox operation (HTTP 402).
RateLimitException
Raised when the account exceeds its rate limit (HTTP 429). Inspect
retry_after and back off before retrying.
Catching all Declaw errors
Idempotent sandbox creation
Sandbox.create and AsyncSandbox.create send an Idempotency-Key
automatically. A create that times out or is retried will not leave a second
running, billable sandbox behind: the key is generated once per logical create
and reused across that call’s retries, so the server replays the original
response instead of starting a new sandbox.
The SDK also retries a 409 carrying idempotency_in_progress on your behalf,
honoring Retry-After. That is how the sandbox ID is recovered when the original
response was lost — you do not need to write that loop.