Class WebClientResponseException

All Implemented Interfaces:
Serializable
Direct Known Subclasses:
UnknownHttpStatusCodeException, WebClientResponseException.BadGateway, WebClientResponseException.BadRequest, WebClientResponseException.Conflict, WebClientResponseException.Forbidden, WebClientResponseException.GatewayTimeout, WebClientResponseException.Gone, WebClientResponseException.InternalServerError, WebClientResponseException.MethodNotAllowed, WebClientResponseException.NotAcceptable, WebClientResponseException.NotFound, WebClientResponseException.NotImplemented, WebClientResponseException.ServiceUnavailable, WebClientResponseException.TooManyRequests, WebClientResponseException.Unauthorized, WebClientResponseException.UnprocessableEntity, WebClientResponseException.UnsupportedMediaType

public class WebClientResponseException extends WebClientException
Exceptions that contain actual HTTP response data.
Since:
5.0
Author:
Arjen Poutsma
See Also:
  • Constructor Details

  • Method Details

    • getStatusCode

      public HttpStatus getStatusCode()
      Return the HTTP status code value.
      Throws:
      IllegalArgumentException - in case of an unknown HTTP status code
    • getRawStatusCode

      public int getRawStatusCode()
      Return the raw HTTP status code value.
    • getStatusText

      public String getStatusText()
      Return the HTTP status text.
    • getHeaders

      public HttpHeaders getHeaders()
      Return the HTTP response headers.
    • getResponseBodyAsByteArray

      public byte[] getResponseBodyAsByteArray()
      Return the response body as a byte array.
    • getResponseBodyAsString

      public String getResponseBodyAsString()
      Return the response content as a String using the charset of media type for the response, if available, or otherwise falling back on ISO-8859-1. Use getResponseBodyAsString(Charset) if you want to fall back on a different, default charset.
    • getResponseBodyAsString

      public String getResponseBodyAsString(Charset defaultCharset)
      Variant of getResponseBodyAsString() that allows specifying the charset to fall back on, if a charset is not available from the media type for the response.
      Parameters:
      defaultCharset - the charset to use if the Content-Type of the response does not specify one.
      Since:
      5.3.7
    • getRequest

      @Nullable public HttpRequest getRequest()
      Return the corresponding request.
      Since:
      5.1.4
    • create

      public static WebClientResponseException create(int statusCode, String statusText, HttpHeaders headers, byte[] body, @Nullable Charset charset)
      Create WebClientResponseException or an HTTP status specific subclass.
      Since:
      5.1
    • create

      public static WebClientResponseException create(int statusCode, String statusText, HttpHeaders headers, byte[] body, @Nullable Charset charset, @Nullable HttpRequest request)
      Create WebClientResponseException or an HTTP status specific subclass.
      Since:
      5.1.4