Error Handling
Learn how to handle errors gracefully in Magical Auth.
Common Error Codes
Error Code | Status | Description |
---|---|---|
CARRIER_NOT_ELIGIBLE | 422 | Carrier doesn't support Magical Auth |
INVALID_PHONE_NUMBER | 400 | Phone number format is invalid |
SESSION_EXPIRED | 404 | Session has expired |
RATE_LIMIT_EXCEEDED | 429 | Too many requests |
Error Handling Example
try {
const result = await glide.magicAuth.getPhoneNumber();
} catch (error) {
switch (error.code) {
case 'CARRIER_NOT_ELIGIBLE':
// Offer SMS fallback
showSMSVerification();
break;
case 'SESSION_EXPIRED':
// Retry the request
retryVerification();
break;
default:
console.error('Unexpected error:', error);
}
}
Best Practices
- Always provide user-friendly error messages
- Implement fallback mechanisms for unsupported carriers
- Log errors for debugging
- Retry transient failures with exponential backoff