Class HttpException

  • All Implemented Interfaces:
    java.io.Serializable

    public final class HttpException
    extends java.io.IOException
    Thrown when an http request fails.

    Exposes the specific status code or UNKNOWN via getStatusCode() so users may attempt to retry or otherwise uniformly handle certain types of errors regardless of the underlying http library.

    See Also:
    Serialized Form
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static int UNKNOWN  
    • Constructor Summary

      Constructors 
      Constructor Description
      HttpException​(int statusCode)  
      HttpException​(java.lang.String message)
      Deprecated.
      You should always include a status code, default to UNKNOWN if you can't come up with a reasonable one.
      HttpException​(java.lang.String message, int statusCode)  
      HttpException​(java.lang.String message, int statusCode, java.lang.Throwable cause)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      int getStatusCode()
      Returns the http status code, or UNKNOWN if the request failed without providing a status code.
      • Methods inherited from class java.lang.Throwable

        addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • HttpException

        public HttpException​(int statusCode)
      • HttpException

        @Deprecated
        public HttpException​(java.lang.String message)
        Deprecated.
        You should always include a status code, default to UNKNOWN if you can't come up with a reasonable one. This method will be removed in a future version.
      • HttpException

        public HttpException​(java.lang.String message,
                             int statusCode)
      • HttpException

        public HttpException​(java.lang.String message,
                             int statusCode,
                             @Nullable
                             java.lang.Throwable cause)
    • Method Detail

      • getStatusCode

        public int getStatusCode()
        Returns the http status code, or UNKNOWN if the request failed without providing a status code.