Overview
The WhatsApp Client SDK provides comprehensive error handling with detailed context, specific error codes, and actionable suggestions. This guide explains how to use the enhanced error system for better debugging and user experience.🔍 Detailed Error Context
Operation details and timestamps, request/response information, phone numbers and message IDs, debugging metadata
📊 Categorized Error Codes
Configuration errors (1000-1099), API errors (2000-2099), webhook errors (3000-3099), media errors (4000-4099), and more
💡 Actionable Suggestions
Specific steps to resolve issues, context-aware recommendations, best practice guidance
🛡️ Enhanced Error Classes
Specialized error classes for different types of failures with rich debugging information
Enhanced Error Classes
EnhancedWhatsAppError (Base Class)
The base class for all enhanced errors provides detailed context and suggestions:ApiRequestError (API Failures)
Specialized for WhatsApp API request failures:WebhookProcessingError (Webhook Issues)
For webhook processing failures:BufferError (Message Buffering Issues)
For message buffer overflow and processing issues:Error Code Reference
Configuration Errors (1000-1099)
Configuration Error Codes
Configuration Error Codes
1001- MISSING_ACCESS_TOKEN1002- MISSING_PHONE_NUMBER_ID1003- MISSING_WEBHOOK_TOKEN1004- INVALID_CONFIGURATION
API Errors (2000-2099)
API Error Codes
API Error Codes
2001- API_REQUEST_FAILED2002- INVALID_PHONE_NUMBER2003- MESSAGE_TOO_LONG2004- UNSUPPORTED_MESSAGE_TYPE2005- TEMPLATE_NOT_FOUND2006- INVALID_MEDIA_ID
Webhook Errors (3000-3099)
Webhook Error Codes
Webhook Error Codes
3001- WEBHOOK_VERIFICATION_FAILED3002- WEBHOOK_PARSING_FAILED3003- WEBHOOK_HANDLER_ERROR3004- INVALID_WEBHOOK_PAYLOAD
Media Errors (4000-4099)
Media Error Codes
Media Error Codes
4001- MEDIA_UPLOAD_FAILED4002- MEDIA_DOWNLOAD_FAILED4003- MEDIA_TOO_LARGE4004- UNSUPPORTED_MEDIA_TYPE
Rate Limit Errors (5000-5099)
Rate Limit Error Codes
Rate Limit Error Codes
5001- RATE_LIMIT_EXCEEDED5002- QUOTA_EXCEEDED
Business Verification Errors (6000-6099)
Business Verification Error Codes
Business Verification Error Codes
6001- BUSINESS_NOT_VERIFIED6002- PHONE_NUMBER_NOT_VERIFIED
Buffer/Processing Errors (7000-7099)
Buffer/Processing Error Codes
Buffer/Processing Error Codes
7001- BUFFER_OVERFLOW7002- MESSAGE_PROCESSING_FAILED7003- HANDLER_EXECUTION_FAILED
Usage Examples
Basic Error Handling
Advanced Webhook Error Handling
Error Monitoring and Logging
Structured Error Logging
Best Practices
1. Always Check Error Types
2. Use Error Codes for Logic
3. Implement Error Recovery
Migration Guide
Before (Old Error Handling)
After (Enhanced Error Handling)
Troubleshooting Common Issues
Buffer Overflow (Error Code: 7001)
Rate Limiting (Error Code: 5001)
Invalid Access Token (Error Code: 1001)
Enhanced error handling is available in SDK version 1.4.1 and later. All error classes are backward compatible with existing error handling patterns.For more error handling patterns and best practices, check out our Best Practices Guide.