Class ServerErrorException

All Implemented Interfaces:
Serializable

public class ServerErrorException extends HttpException
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 Details

    • ServerErrorException

      public ServerErrorException(int statusCode, String message, Request request, Response response)
      Creates a ServerErrorException.
      Parameters:
      statusCode - the HTTP status code (5xx)
      message - descriptive error message
      request - the original HTTP request
      response - 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 message
      request - the original HTTP request
      response - the HTTP response
      cause - 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
    • isServiceUnavailable

      public boolean isServiceUnavailable()
      Check if this is a 503 Service Unavailable error.
      Returns:
      true if status code is 503
    • 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:
      isRetryable in class HttpException
      Returns:
      true for all 5xx except 501