Error Types
S2Error
The top-level error type for SDK operations:Error Categories
1
API Errors
Server-side errors with specific error codes:
2
Client Errors
SDK-side errors from session management:
3
Network Errors
Transport and connectivity issues:
4
Validation Errors
Input validation failures:
Retryable vs Terminal Errors
Retryable Errors
These errors are automatically retried by sessions:- Acknowledgement timeout
- Server disconnection
- Heartbeat timeout (read sessions)
- Transient network errors
- Server unavailability (503)
- Gateway timeout (504)
Terminal Errors
These errors end the operation immediately:- Invalid input (400)
- Permission denied (403)
- Resource not found (404)
- Conflict (409)
- Quota exhausted (403)
- Session closed
- Session dropped
Terminal errors indicate a problem that cannot be resolved by retrying. Handle them explicitly in your application logic.
Automatic Retry with Backoff
Sessions implement exponential backoff with jitter:Backoff Behavior
Fromretry.rs:79-97:
Retry Reset
Backoff resets on successful operations:Error Handling Patterns
Pattern 1: Basic Error Handling
Pattern 2: Graceful Degradation
Pattern 3: Circuit Breaker
Pattern 4: Error Aggregation
Append-Specific Errors
Append Condition Failed
When using fencing tokens or sequence number matching:Read-Specific Errors
Heartbeat Timeout
Validation Errors
Catch validation errors early:Best Practices
Always call
close() on sessions, even after errors, to ensure proper cleanup and resource release.