Error Recovery
Handle errors gracefully and provide a great user experience.
Error Types
The SDK provides typed errors for better handling:
import { DotPassportError } from '@dotpassport/sdk';
try {
const scores = await client.getScores(address);
} catch (error) {
if (error instanceof DotPassportError) {
console.log('Status:', error.statusCode);
console.log('Message:', error.message);
}
}Common Error Codes
Status Code
Meaning
Recovery Strategy
400
Invalid request
Validate input parameters
401
Invalid API key
Check API key configuration
404
Address not found
Show "new user" state
429
Rate limited
Implement retry with backoff
500
Server error
Retry after delay
503
Service unavailable
Retry with exponential backoff
Retry with Exponential Backoff
Graceful Degradation
Show fallback UI when data can't be loaded:
React Error Boundary
Widget Error Handling
Handle errors directly in widget callbacks:
Network Error Handling
Detect and handle network issues:
Timeout Handling
Add timeouts to prevent hanging requests:
Error Logging
Log errors for debugging and monitoring:
Complete Error Recovery Example
Related
Last updated
