Class ExtendedHttpResponseException

java.lang.Object
java.lang.Throwable
java.lang.Exception
java.io.IOException
org.apache.hc.client5.http.ClientProtocolException
org.apache.hc.client5.http.HttpResponseException
com.helger.httpclient.response.ExtendedHttpResponseException
All Implemented Interfaces:
Serializable

public class ExtendedHttpResponseException extends org.apache.hc.client5.http.HttpResponseException
A specialized version of HttpResponseException that has access to all the fields in a structured way.
Since:
8.8.1
Author:
Philip Helger
See Also:
  • Constructor Details

    • ExtendedHttpResponseException

      public ExtendedHttpResponseException(@Nonnull org.apache.hc.core5.http.message.StatusLine aStatusLine, @Nonnull org.apache.hc.core5.http.HttpResponse aHttpResponse, @Nullable byte[] aResponseBody, @Nonnull Charset aCharset)
  • Method Details

    • getStatusLine

      @Nonnull public final org.apache.hc.core5.http.message.StatusLine getStatusLine()
      Returns:
      The status line received. Never null.
    • getHttpResponse

      @Nonnull public final org.apache.hc.core5.http.HttpResponse getHttpResponse()
      Returns:
      The HTTP response object that triggered the exception. May not be null. May be used to determine the headers of the response.
    • directGetResponseBody

      @Nullable @ReturnsMutableObject public final byte[] directGetResponseBody()
      Returns:
      The response body bytes. May be null.
    • getResponseBody

      @Nullable @ReturnsMutableCopy public final byte[] getResponseBody()
      Returns:
      A copy of the response body bytes. May be null.
    • hasResponseBody

      public final boolean hasResponseBody()
      Returns:
      true if a response body is present, false otherwise.
    • getResponseCharset

      @Nonnull public final Charset getResponseCharset()
      Returns:
      The response charset. Never null.
    • getResponseBodyAsString

      @Nullable public final String getResponseBodyAsString()
      Returns:
      The response body as a string in the response charset. May be null if no response body is present.
      See Also:
    • getResponseBodyAsString

      @Nullable public final String getResponseBodyAsString(@Nonnull Charset aCharset)
      Get the response body as a string in the provided charset.
      Parameters:
      aCharset - The charset to use. May not be null.
      Returns:
      null if no response body is present.
    • getMessagePartStatusLine

      @Nonnull @Nonempty public String getMessagePartStatusLine()
    • getMessagePartHeaders

      @Nonnull @Nonempty public String getMessagePartHeaders()
    • getMessagePartResponseBody

      @Nonnull @Nonempty public String getMessagePartResponseBody()
    • getMessage

      @Nonnull public String getMessage()
      Overrides:
      getMessage in class Throwable
    • create

      @Nonnull public static ExtendedHttpResponseException create(@Nonnull org.apache.hc.core5.http.ClassicHttpResponse aHttpResponse) throws IOException
      Throws:
      IOException
    • create

      @Nonnull public static ExtendedHttpResponseException create(@Nonnull org.apache.hc.core5.http.message.StatusLine aStatusLine, @Nonnull org.apache.hc.core5.http.HttpResponse aHttpResponse, @Nonnull org.apache.hc.core5.http.HttpEntity aEntity) throws IOException
      Throws:
      IOException