Exceptions API Reference

Exception classes for WhatsApp SDK.

Custom exceptions for different error scenarios in the SDK.

exception whatsapp_sdk.exceptions.WhatsAppError[source]

Bases: Exception

Base exception for all WhatsApp SDK errors.

exception whatsapp_sdk.exceptions.WhatsAppAPIError[source]

Bases: WhatsAppError

General API error from WhatsApp.

exception whatsapp_sdk.exceptions.WhatsAppAuthenticationError[source]

Bases: WhatsAppError

Authentication/authorization error.

exception whatsapp_sdk.exceptions.WhatsAppRateLimitError[source]

Bases: WhatsAppError

Rate limit exceeded error.

exception whatsapp_sdk.exceptions.WhatsAppValidationError[source]

Bases: WhatsAppError

Request validation error.

exception whatsapp_sdk.exceptions.WhatsAppWebhookError[source]

Bases: WhatsAppError

Webhook processing error.

exception whatsapp_sdk.exceptions.WhatsAppMediaError[source]

Bases: WhatsAppError

Media upload/download error.

exception whatsapp_sdk.exceptions.WhatsAppTimeoutError[source]

Bases: WhatsAppError

Request timeout error.

exception whatsapp_sdk.exceptions.WhatsAppConfigError[source]

Bases: WhatsAppError

Configuration 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}")