Class FailedRequestException

  • All Implemented Interfaces:
    Serializable

    public class FailedRequestException
    extends IOException

    A special exception class to report errors caused by requests that have an unexpected (typically non-success) status code.

    This exception class stores the response status code, so that it is available for further investigation. A cause is not available because the request completed normally. In order to identify the request that failed, a tag can be provided that is added to the exception message. This is useful if a future is constructed from the results of multiple requests.

    See Also:
    Serialized Form
    • Constructor Detail

      • FailedRequestException

        public FailedRequestException​(String tag,
                                      int statusCode)
        Creates a new instance of FailedRequestException and initializes it with a tag and the status code that caused the exception.
        Parameters:
        tag - a tag to identify the failed request
        statusCode - the HTTP status code
      • FailedRequestException

        public FailedRequestException​(String tag,
                                      int statusCode,
                                      String serverMessage)
        Creates a new instance of FailedRequestException and initializes it with a tag, the error status code, and the message sent from the server as response to the failed request.
        Parameters:
        tag - a tag to identify the failed request
        statusCode - the HTTP status code
        serverMessage - the error message sent by the server
    • Method Detail

      • getStatusCode

        public int getStatusCode()
        Returns the response status code that caused this exception.
        Returns:
        the HTTP status code of the failed response
      • getTag

        public String getTag()
        Returns a tag to identify the failed request. Result can be null if no tag has been provided.
        Returns:
        a tag for the failed request