Exceptions API Reference
Exception classes for WhatsApp SDK.
Custom exceptions for different error scenarios in the SDK.
- exception whatsapp_sdk.exceptions.WhatsAppError[source]
Bases:
ExceptionBase exception for all WhatsApp SDK errors.
- exception whatsapp_sdk.exceptions.WhatsAppAPIError[source]
Bases:
WhatsAppErrorGeneral API error from WhatsApp.
- exception whatsapp_sdk.exceptions.WhatsAppAuthenticationError[source]
Bases:
WhatsAppErrorAuthentication/authorization error.
- exception whatsapp_sdk.exceptions.WhatsAppRateLimitError[source]
Bases:
WhatsAppErrorRate limit exceeded error.
- exception whatsapp_sdk.exceptions.WhatsAppValidationError[source]
Bases:
WhatsAppErrorRequest validation error.
- exception whatsapp_sdk.exceptions.WhatsAppWebhookError[source]
Bases:
WhatsAppErrorWebhook processing error.
- exception whatsapp_sdk.exceptions.WhatsAppMediaError[source]
Bases:
WhatsAppErrorMedia upload/download error.
- exception whatsapp_sdk.exceptions.WhatsAppTimeoutError[source]
Bases:
WhatsAppErrorRequest timeout error.
- exception whatsapp_sdk.exceptions.WhatsAppConfigError[source]
Bases:
WhatsAppErrorConfiguration error.
Exception Hierarchy
WhatsAppError
├── WhatsAppAPIError
├── WhatsAppAuthError
├── WhatsAppRateLimitError
├── WhatsAppValidationError
├── WhatsAppWebhookError
└── WhatsAppMediaError
Usage Examples
from whatsapp_sdk.exceptions import WhatsAppError, WhatsAppAPIError
try:
response = client.messages.send_text(
to="+invalid",
body="Hello"
)
except WhatsAppValidationError as e:
print(f"Validation error: {e.message}")
except WhatsAppAPIError as e:
print(f"API error: {e.code} - {e.message}")
except WhatsAppError as e:
print(f"General error: {e}")