Skip to content
sistemo.io beta
GitHub Docs Quickstart

Error handling (Python)

All SDK exceptions subclass SistemoError.

from sistemo import (
    Sandbox,
    SistemoError,    # base class
    APIError,        # non-2xx response (has .status, .detail, .code)
    AuthError,       # 401 / 403 — key missing, invalid, revoked, or wrong scope
    NotFoundError,   # 404 — resource not found (or not yours)
    RateLimitError,  # 429 — slow down
)

Hierarchy

SistemoError
└── APIError(status, detail, code)
    ├── AuthError       (401, 403)
    ├── NotFoundError   (404)
    └── RateLimitError  (429)

SistemoError (not APIError) is also raised for client-side problems like a missing API key or a connection failure.

Handling specific cases

from sistemo import Sandbox, AuthError, RateLimitError, APIError

try:
    with Sandbox() as sb:
        print(sb.run("echo hi").stdout)
except AuthError:
    print("Check SISTEMO_API_KEY — it may be missing, revoked, or read-only.")
except RateLimitError:
    print("Rate limited — back off and retry.")
except APIError as e:
    print(f"API error {e.status}: {e.detail} ({e.code})")

Fields on APIError

Field Example
status 403
detail "Machine quota exceeded (limit 1)."
code "quota_exceeded"

See API errors for the full list of code values.