Error Types
All SDK errors follow theDecartSDKError type:
Error Codes
The SDK defines these error codes:Basic Error Handling
Process API (Synchronous)
Queue API (Async Jobs)
Real-Time Error Handling
For real-time connections, handle errors via the event emitter:Diagnostic Events
For real-time connections, you can also listen to diagnostic events:Retry Strategies
Exponential Backoff
Queue Polling with Timeout
React Error Boundaries
For React applications, use error boundaries to catch rendering errors:Best Practices
- Always handle errors - Never ignore try/catch blocks
- Check error codes - Use specific error codes to provide better feedback
- Retry transient errors - Network issues, timeouts, etc.
- Don’t retry permanent errors - Invalid API keys, bad input, etc.
- Log errors - Keep track of failures for debugging
- Show user-friendly messages - Don’t expose technical details to users
- Monitor connection state - React to state changes in real-time connections
- Use diagnostic events - Track video stalls and other issues
- Set timeouts - Don’t wait indefinitely for responses
- Clean up resources - Disconnect clients, revoke object URLs, etc.
Next Steps
- React Integration - React-specific patterns
- Real-Time API Reference - Connection API details
- Process API Reference - Synchronous generation API
- Queue API Reference - Async job API