org.springframework.web.reactive.function.client

## Class WebClientResponseException

- java.lang.Object
- - java.lang.Throwable
  - - java.lang.Exception
    - - java.lang.RuntimeException
      - - org.springframework.core.NestedRuntimeException
        - - org.springframework.web.reactive.function.client.WebClientException
          - - org.springframework.web.reactive.function.client.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:
  Serialized Form

### Nested Class Summary

Nested Classes
`static class` `WebClientResponseException.BadGateway` `WebClientResponseException` for status HTTP HTTP 502 Bad Gateway.
`static class` `WebClientResponseException.BadRequest` `WebClientResponseException` for status HTTP 400 Bad Request.
`static class` `WebClientResponseException.Conflict` `WebClientResponseException` for status HTTP 409 Conflict.
`static class` `WebClientResponseException.Forbidden` `WebClientResponseException` for status HTTP 403 Forbidden.
`static class` `WebClientResponseException.GatewayTimeout` `WebClientResponseException` for status HTTP 504 Gateway Timeout.
`static class` `WebClientResponseException.Gone` `WebClientResponseException` for status HTTP 410 Gone.
`static class` `WebClientResponseException.InternalServerError` `WebClientResponseException` for status HTTP 500 Internal Server Error.
`static class` `WebClientResponseException.MethodNotAllowed` `WebClientResponseException` for status HTTP 405 Method Not Allowed.
`static class` `WebClientResponseException.NotAcceptable` `WebClientResponseException` for status HTTP 406 Not Acceptable.
`static class` `WebClientResponseException.NotFound` `WebClientResponseException` for status HTTP 404 Not Found.
`static class` `WebClientResponseException.NotImplemented` `WebClientResponseException` for status HTTP 501 Not Implemented.
`static class` `WebClientResponseException.ServiceUnavailable` `WebClientResponseException` for status HTTP 503 Service Unavailable.
`static class` `WebClientResponseException.TooManyRequests` `WebClientResponseException` for status HTTP 429 Too Many Requests.
`static class` `WebClientResponseException.Unauthorized` `WebClientResponseException` for status HTTP 401 Unauthorized.
`static class` `WebClientResponseException.UnprocessableEntity` `WebClientResponseException` for status HTTP 422 Unprocessable Entity.
`static class` `WebClientResponseException.UnsupportedMediaType` `WebClientResponseException` for status HTTP 415 Unsupported Media Type.

### Constructor Summary

Constructors
Constructor and Description
`WebClientResponseException(int statusCode, String statusText, org.springframework.http.HttpHeaders headers, byte[] body, Charset charset)` Constructor with response data only, and a default message.
`WebClientResponseException(int status, String reasonPhrase, org.springframework.http.HttpHeaders headers, byte[] body, Charset charset, org.springframework.http.HttpRequest request)` Constructor with response data only, and a default message.
`WebClientResponseException(String message, int statusCode, String statusText, org.springframework.http.HttpHeaders headers, byte[] responseBody, Charset charset)` Constructor with a prepared message.
`WebClientResponseException(String message, int statusCode, String statusText, org.springframework.http.HttpHeaders headers, byte[] responseBody, Charset charset, org.springframework.http.HttpRequest request)` Constructor with a prepared message.

### Method Summary

All Methods Static Methods Instance Methods Concrete Methods
`static WebClientResponseException` `create(int statusCode, String statusText, org.springframework.http.HttpHeaders headers, byte[] body, Charset charset)` Create `WebClientResponseException` or an HTTP status specific subclass.
`static WebClientResponseException` `create(int statusCode, String statusText, org.springframework.http.HttpHeaders headers, byte[] body, Charset charset, org.springframework.http.HttpRequest request)` Create `WebClientResponseException` or an HTTP status specific subclass.
`org.springframework.http.HttpHeaders` `getHeaders()` Return the HTTP response headers.
`int` `getRawStatusCode()` Return the raw HTTP status code value.
`org.springframework.http.HttpRequest` `getRequest()` Return the corresponding request.
`byte[]` `getResponseBodyAsByteArray()` Return the response body as a byte array.
`String` `getResponseBodyAsString()` Return the response body as a string.
`org.springframework.http.HttpStatus` `getStatusCode()` Return the HTTP status code value.
`String` `getStatusText()` Return the HTTP status text.

### Methods inherited from class org.springframework.core.NestedRuntimeException

`contains, getMessage, getMostSpecificCause, getRootCause`

### Methods inherited from class java.lang.Throwable

`addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, 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

#### WebClientResponseException

    public WebClientResponseException(int statusCode,
                                      String statusText,
                                      @Nullable
                                      org.springframework.http.HttpHeaders headers,
                                      @Nullable
                                      byte[] body,
                                      @Nullable
                                      Charset charset)

Constructor with response data only, and a default message.

Since:
  5.1

#### WebClientResponseException

    public WebClientResponseException(int status,
                                      String reasonPhrase,
                                      @Nullable
                                      org.springframework.http.HttpHeaders headers,
                                      @Nullable
                                      byte[] body,
                                      @Nullable
                                      Charset charset,
                                      @Nullable
                                      org.springframework.http.HttpRequest request)

Constructor with response data only, and a default message.

Since:
  5.1.4

#### WebClientResponseException

    public WebClientResponseException(String message,
                                      int statusCode,
                                      String statusText,
                                      @Nullable
                                      org.springframework.http.HttpHeaders headers,
                                      @Nullable
                                      byte[] responseBody,
                                      @Nullable
                                      Charset charset)

Constructor with a prepared message.

#### WebClientResponseException

    public WebClientResponseException(String message,
                                      int statusCode,
                                      String statusText,
                                      @Nullable
                                      org.springframework.http.HttpHeaders headers,
                                      @Nullable
                                      byte[] responseBody,
                                      @Nullable
                                      Charset charset,
                                      @Nullable
                                      org.springframework.http.HttpRequest request)

Constructor with a prepared message.

Since:
  5.1.4

### Method Detail

#### getStatusCode

    public org.springframework.http.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 org.springframework.http.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 body as a string.

#### getRequest

    @Nullable
    public org.springframework.http.HttpRequest getRequest()

Return the corresponding request.

Since:
  5.1.4

#### create

    public static WebClientResponseException create(int statusCode,
                                                    String statusText,
                                                    org.springframework.http.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,
                                                    org.springframework.http.HttpHeaders headers,
                                                    byte[] body,
                                                    @Nullable
                                                    Charset charset,
                                                    @Nullable
                                                    org.springframework.http.HttpRequest request)

Create `WebClientResponseException` or an HTTP status specific subclass.

Since:
  5.1.4