Error Handling
The Chucky SDK provides a comprehensive error hierarchy to help you handle different failure scenarios appropriately.Error Classes
All SDK errors extend fromChuckyError:
Error Hierarchy
Error Properties
Handling Errors
Basic Error Handling
Specific Error Types
Error Codes
| Code | Error Class | HTTP Status | Description |
|---|---|---|---|
token_expired | AuthenticationError | 401 | Token has expired |
user_budget_exhausted | BudgetExceededError | 429 | User’s per-app budget exceeded |
developer_budget_exhausted | BudgetExceededError | 402 | Service compute quota exhausted |
concurrent_limit_reached | ConcurrencyLimitError | 429 | Max concurrent sessions reached |
CONNECTION_ERROR | ConnectionError | - | WebSocket connection failed |
RATE_LIMIT | RateLimitError | 429 | Too many requests |
SESSION_ERROR | SessionError | - | Session operation failed |
TOOL_EXECUTION_ERROR | ToolExecutionError | - | Tool handler threw error |
TIMEOUT | TimeoutError | - | Operation timed out |
VALIDATION_ERROR | ValidationError | 400 | Invalid input |
Server Error Responses
The server returns errors with both a machine-readableerror code and a human-readable message:
Error Messages
| Error Code | User-Friendly Message |
|---|---|
token_expired | ”Your session token has expired. Please request a new token from the application.” |
user_budget_exhausted | ”You have reached your usage limit for this app. Please contact the app developer to increase your limit.” |
developer_budget_exhausted | ”This service has exhausted its compute quota for the current billing period. Please try again later or contact the service provider.” |
concurrent_limit_reached | ”Maximum concurrent sessions reached (X/Y). Please wait for an existing session to complete before starting a new one.” |
Connection Errors
Concurrency Errors
Budget Errors
Session Errors
Tool Execution Errors
Handle errors in tool handlers:ToolExecutionError: