Errors
TL;DR
Relay, core, and transport failures normalized by the SDK are CmdopError
instances with a stable code, message, retryability flag, optional HTTP status,
and optional redacted details.
Local usage and client-invariant failures can be plain Error instances. For
example, this includes an invalid timeout or limit, an empty ask without an
attachment, and an unexpected response shape. Use CmdopError as the base class
for normalized operational failures, not as a catch-all for every JavaScript or
Python exception.
Hierarchy
| Type | Meaning |
|---|---|
AuthError | Credentials are missing or invalid. |
PermissionError | The caller is authenticated but not permitted. |
NotFoundError | The requested machine or resource was not found. |
ConflictError | The request conflicts with current state. |
ValidationError | An input is invalid. |
RateLimitError | The relay is rate limiting the caller. |
ServerError | The relay or core failed internally. |
ConnectionError | The core process or transport failed. |
TimeoutError | A deadline expired; this error is retryable. |
UnavailableError | The relay is reachable but the target is unavailable. |
UnsupportedError | The requested capability is unsupported. |
ProtocolError | A protocol contract was violated. |
AgentStreamError | machines.ask().collect() reached an unsuccessful terminal outcome. |
Handle errors
from cmdop import CmdopError, UnavailableError
try:
history = await client.machines.messages(machine_id, limit=100)
except UnavailableError:
print("Machine is unavailable")
except CmdopError as error:
print(error.code, error.status, error.retryable)import { CmdopError, UnavailableError } from "@cmdop/sdk";
try {
const history = await client.machines.messages(machineId, { limit: 100 });
} catch (error) {
if (error instanceof UnavailableError) console.log("Machine is unavailable");
else if (error instanceof CmdopError) {
console.log(error.code, error.status, error.retryable);
}
}Retry only when retryable is true and the operation is safe for your
application to repeat.
Last updated on