Package com.chargebee.v4.exceptions
Class ServerErrorException
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.HttpException
com.chargebee.v4.exceptions.ServerErrorException
- All Implemented Interfaces:
Serializable
Exception for 5xx HTTP status codes (server errors).
Server errors indicate issues on the server side that may be temporary:
- 500 Internal Server Error - Unexpected server error
- 501 Not Implemented - Feature not supported (not retryable)
- 502 Bad Gateway - Gateway/proxy error
- 503 Service Unavailable - Server overloaded or maintenance
- 504 Gateway Timeout - Gateway/proxy timeout
Most 5xx errors are retryable (except 501):
try {
client.customers().list();
} catch (ServerErrorException e) {
if (e.isRetryable()) {
// Exponential backoff retry
} else if (e.isNotImplemented()) {
// Feature not available
}
}
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionServerErrorException(int statusCode, String message, Request request, Response response) Creates a ServerErrorException.ServerErrorException(int statusCode, String message, Request request, Response response, Throwable cause) Creates a ServerErrorException with cause. -
Method Summary
Modifier and TypeMethodDescriptionbooleanCheck if this is a 502 Bad Gateway error.booleanCheck if this is a 504 Gateway Timeout error.booleanCheck if this is a 500 Internal Server Error.booleanCheck if this is a 501 Not Implemented error.booleanServer errors are generally retryable, except 501 (Not Implemented).booleanCheck if this is a 503 Service Unavailable error.Methods inherited from class com.chargebee.v4.exceptions.HttpException
getResponse, getResponseBody, getStatusCode, isClientError, isServerError, toStringMethods 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
-
Constructor Details
-
ServerErrorException
Creates a ServerErrorException.- Parameters:
statusCode- the HTTP status code (5xx)message- descriptive error messagerequest- the original HTTP requestresponse- the HTTP response
-
ServerErrorException
public ServerErrorException(int statusCode, String message, Request request, Response response, Throwable cause) Creates a ServerErrorException with cause.- Parameters:
statusCode- the HTTP status code (5xx)message- descriptive error messagerequest- the original HTTP requestresponse- the HTTP responsecause- the underlying cause
-
-
Method Details
-
isInternalServerError
public boolean isInternalServerError()Check if this is a 500 Internal Server Error.- Returns:
- true if status code is 500
-
isNotImplemented
public boolean isNotImplemented()Check if this is a 501 Not Implemented error. This error is NOT retryable as the feature is not supported.- Returns:
- true if status code is 501
-
isBadGateway
public boolean isBadGateway()Check if this is a 502 Bad Gateway error.- Returns:
- true if status code is 502
-
isGatewayTimeout
public boolean isGatewayTimeout()Check if this is a 504 Gateway Timeout error.- Returns:
- true if status code is 504
-
isRetryable
public boolean isRetryable()Server errors are generally retryable, except 501 (Not Implemented).Retryable server errors (temporary issues):
- 500 Internal Server Error
- 502 Bad Gateway
- 503 Service Unavailable
- 504 Gateway Timeout
- Overrides:
isRetryablein classHttpException- Returns:
- true for all 5xx except 501
-