Package com.chargebee.v4.exceptions
Class ChargebeeException
java.lang.Object
java.lang.Throwable
java.lang.Exception
java.lang.RuntimeException
com.chargebee.v4.exceptions.ChargebeeException
- All Implemented Interfaces:
Serializable
- Direct Known Subclasses:
ConfigurationException,TransportException
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
}
-
Constructor Summary
ConstructorsConstructorDescriptionChargebeeException(String message) Constructs a new exception with the specified detail message.ChargebeeException(String message, Throwable cause) Constructs a new exception with the specified detail message and cause. -
Method Summary
Modifier and TypeMethodDescriptionbooleanIndicates whether retrying the failed operation might succeed.Methods inherited from class java.lang.Throwable
addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString
-
Constructor Details
-
ChargebeeException
Constructs a new exception with the specified detail message.- Parameters:
message- the detail message describing the error condition
-
ChargebeeException
Constructs a new exception with the specified detail message and cause.- Parameters:
message- the detail message describing the error conditioncause- 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:
NetworkException— returnstrue(transient connectivity issues)TimeoutException— returnstrue(temporary overload)ServerErrorException— returnstruefor 5xx except 501ClientErrorException— returnstrueonly for 429 (rate limited)ConfigurationException— returnsfalse(requires code fix)
- Returns:
trueif the operation may succeed on retry;falseotherwise
-