Package com.chargebee.v4.exceptions
Class TimeoutException
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.TimeoutException
- All Implemented Interfaces:
Serializable
Exception for connection or read timeouts during HTTP communication.
This exception inherits request context from TransportException and adds:
getTimeoutType()- Whether it was a "connect" or "read" timeoutisConnectTimeout()/isReadTimeout()- Convenient type checks
Inherited from base class:
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 (TimeoutException e) {
System.err.println("Timeout type: " + e.getTimeoutType());
System.err.println("Failed URL: " + e.getUrl());
if (e.isConnectTimeout()) {
// Server might be down or unreachable
} else if (e.isReadTimeout()) {
// Server is slow to respond, consider increasing timeout
}
if (e.isRetryable()) {
// Implement retry logic
}
}
- See Also:
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionTimeoutException(String timeoutType, String message, Throwable cause) Creates a TimeoutException without request context.TimeoutException(String timeoutType, String message, Throwable cause, Request request) Creates a TimeoutException with request context. -
Method Summary
Modifier and TypeMethodDescriptionGet the type of timeout that occurred.booleanCheck if this was a connection timeout.booleanCheck if this was a read timeout.booleanTimeouts are generally retryable as they may be transient (e.g., temporary server load, network congestion).toString()Methods inherited from class com.chargebee.v4.exceptions.TransportException
getHttpMethod, getRequest, getUrlMethods inherited from class java.lang.Throwable
addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace
-
Field Details
-
CONNECT
Timeout type for connection timeouts.- See Also:
-
READ
Timeout type for read timeouts.- See Also:
-
-
Constructor Details
-
TimeoutException
Creates a TimeoutException with request context.- Parameters:
timeoutType- the type of timeout ("connect" or "read")message- descriptive error messagecause- the underlying causerequest- the HTTP request that timed out
-
TimeoutException
Creates a TimeoutException without request context. PreferTimeoutException(String, String, Throwable, Request)when request is available.- Parameters:
timeoutType- the type of timeout ("connect" or "read")message- descriptive error messagecause- the underlying cause
-
-
Method Details
-
getTimeoutType
Get the type of timeout that occurred.- Returns:
- "connect" for connection timeouts, "read" for read timeouts
-
isConnectTimeout
public boolean isConnectTimeout()Check if this was a connection timeout. Connection timeouts occur when the server cannot be reached within the connect timeout period.- Returns:
- true if this is a connection timeout
-
isReadTimeout
public boolean isReadTimeout()Check if this was a read timeout. Read timeouts occur when the server doesn't respond within the read timeout period.- Returns:
- true if this is a read timeout
-
isRetryable
public boolean isRetryable()Timeouts are generally retryable as they may be transient (e.g., temporary server load, network congestion).- Overrides:
isRetryablein classTransportException- Returns:
- true, indicating this error is typically retryable
-
toString
- Overrides:
toStringin classTransportException
-