Package com.chargebee.v4.exceptions
Class NetworkException
java.lang.Object
java.lang.Throwable
java.lang.Exception
java.lang.RuntimeException
com.chargebee.v4.exceptions.ChargebeeException
com.chargebee.v4.exceptions.TransportException
com.chargebee.v4.exceptions.NetworkException
- All Implemented Interfaces:
Serializable
Exception for network connectivity issues such as DNS failures, connection refused,
or general I/O errors during HTTP communication.
This exception inherits request context from TransportException:
TransportException.getUrl()- The URL that was being accessedTransportException.getHttpMethod()- The HTTP method (GET, POST, etc.)TransportException.getRequest()- The full request object if needed
Example usage:
try {
client.customers().list();
} catch (NetworkException e) {
System.err.println("Failed to connect to: " + e.getUrl());
System.err.println("Method: " + e.getHttpMethod());
System.err.println("Cause: " + e.getCause().getMessage());
if (e.isRetryable()) {
// Implement retry logic
}
}
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionNetworkException(String message, Throwable cause) Creates a NetworkException without request context.NetworkException(String message, Throwable cause, Request request) Creates a NetworkException with request context. -
Method Summary
Modifier and TypeMethodDescriptionbooleanNetwork errors are generally retryable as they may be transient (e.g., temporary DNS issues, network hiccups).Methods inherited from class com.chargebee.v4.exceptions.TransportException
getHttpMethod, getRequest, getUrl, toStringMethods inherited from class java.lang.Throwable
addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace
-
Constructor Details
-
NetworkException
Creates a NetworkException with request context.- Parameters:
message- descriptive error messagecause- the underlying cause (e.g., IOException)request- the HTTP request that failed
-
NetworkException
Creates a NetworkException without request context. PreferNetworkException(String, Throwable, Request)when request is available.- Parameters:
message- descriptive error messagecause- the underlying cause
-
-
Method Details
-
isRetryable
public boolean isRetryable()Network errors are generally retryable as they may be transient (e.g., temporary DNS issues, network hiccups).- Overrides:
isRetryablein classTransportException- Returns:
- true, indicating this error is typically retryable
-