Class ChargebeeException

All Implemented Interfaces:
Serializable
Direct Known Subclasses:
ConfigurationException, TransportException

public class ChargebeeException extends RuntimeException
The root exception class for all errors originating from the Chargebee SDK.

ChargebeeException serves as the unified base for the SDK's exception hierarchy, enabling developers to catch all Chargebee-related errors with a single exception type while still allowing fine-grained handling of specific error categories.

Exception Hierarchy

 ChargebeeException
 ├── ConfigurationException     — Invalid SDK configuration (missing API key, malformed URL)
 └── TransportException         — Runtime communication errors
     ├── NetworkException       — Connection failures, DNS resolution errors
     ├── TimeoutException       — Connect or read timeout exceeded
     └── HttpException          — HTTP-level errors (4xx, 5xx responses)
         ├── ClientErrorException   — Client errors (400-499)
         ├── ServerErrorException   — Server errors (500-599)
         └── APIException           — Chargebee API errors with structured details
 

Usage Patterns

Catch-all handling


 try {
     client.subscriptions().create(params);
 } catch (ChargebeeException e) {
     log.error("Chargebee operation failed: {}", e.getMessage());
     if (e.isRetryable()) {
         // Schedule retry
     }
 }
 

Granular error handling


 try {
     client.subscriptions().create(params);
 } catch (InvalidRequestException e) {
     // Handle validation errors - check e.getParams() for invalid fields
 } catch (PaymentException e) {
     // Handle payment failures - check e.getErrorCauseId() for gateway details
 } catch (NetworkException | TimeoutException e) {
     // Handle transient failures - safe to retry
 } catch (ChargebeeException e) {
     // Fallback for unexpected SDK errors
 }
 
See Also:
  • Constructor Details

    • ChargebeeException

      public ChargebeeException(String message)
      Constructs a new exception with the specified detail message.
      Parameters:
      message - the detail message describing the error condition
    • ChargebeeException

      public ChargebeeException(String message, Throwable cause)
      Constructs a new exception with the specified detail message and cause.
      Parameters:
      message - the detail message describing the error condition
      cause - the underlying exception that triggered this error
  • Method Details

    • isRetryable

      public boolean isRetryable()
      Indicates whether retrying the failed operation might succeed.

      Subclasses override this method to provide accurate retry guidance:

      Returns:
      true if the operation may succeed on retry; false otherwise