Top Description Inners Fields Constructors Methods
org.springframework.web.reactive.function.client

public Class WebClientResponseException

extends WebClientException
Class Inheritance
Known Direct Subclasses
org.springframework.web.reactive.function.client.WebClientResponseException.BadRequest, org.springframework.web.reactive.function.client.WebClientResponseException.Unauthorized, org.springframework.web.reactive.function.client.WebClientResponseException.Forbidden, org.springframework.web.reactive.function.client.WebClientResponseException.NotFound, org.springframework.web.reactive.function.client.WebClientResponseException.MethodNotAllowed, org.springframework.web.reactive.function.client.WebClientResponseException.NotAcceptable, org.springframework.web.reactive.function.client.WebClientResponseException.Conflict, org.springframework.web.reactive.function.client.WebClientResponseException.Gone, org.springframework.web.reactive.function.client.WebClientResponseException.UnsupportedMediaType, org.springframework.web.reactive.function.client.WebClientResponseException.UnprocessableEntity, org.springframework.web.reactive.function.client.WebClientResponseException.TooManyRequests, org.springframework.web.reactive.function.client.WebClientResponseException.InternalServerError, org.springframework.web.reactive.function.client.WebClientResponseException.NotImplemented, org.springframework.web.reactive.function.client.WebClientResponseException.BadGateway, org.springframework.web.reactive.function.client.WebClientResponseException.ServiceUnavailable, org.springframework.web.reactive.function.client.WebClientResponseException.GatewayTimeout, org.springframework.web.reactive.function.client.UnknownHttpStatusCodeException
Annotations
@SuppressWarnings:RedundantSuppression
Imports
java.nio.charset.Charset, .StandardCharsets, java.util.List, .Map, java.util.function.Function, org.springframework.core.ParameterizedTypeReference, .ResolvableType, org.springframework.http.HttpHeaders, .HttpRequest, .HttpStatus, .HttpStatusCode, org.springframework.lang.Nullable, org.springframework.util.Assert

Exceptions that contain actual HTTP response data.
Authors
Arjen Poutsma, Sebastien Deleuze
Since
5.0

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static class
public static class
public static class
public static class
public static class
public static class
public static class
public static class
public static class
public static class
public static class
public static class
public static class
public static class
public static class
public static class

Field Summary

Modifier and TypeField and Description
private transient Function<ResolvableType, ?>
private final HttpHeaders
private final transient HttpRequest
private final byte[]
private final Charset
private static final long
private final HttpStatusCode
private final String

Constructor Summary

AccessConstructor and Description
public
WebClientResponseException(int statusCode, String statusText, HttpHeaders headers, byte[] body, Charset charset)

Constructor with response data only, and a default message.

public
WebClientResponseException(int status, String reasonPhrase, HttpHeaders headers, byte[] body, Charset charset, HttpRequest request)

Constructor with response data only, and a default message.

public
WebClientResponseException(HttpStatusCode statusCode, String reasonPhrase, HttpHeaders headers, byte[] body, Charset charset, HttpRequest request)

Constructor with response data only, and a default message.

public
WebClientResponseException(String message, int statusCode, String statusText, HttpHeaders headers, byte[] responseBody, Charset charset)

Constructor with a prepared message.

public
WebClientResponseException(String message, int statusCode, String statusText, HttpHeaders headers, byte[] responseBody, Charset charset, HttpRequest request)

Constructor with a prepared message.

public
WebClientResponseException(String message, HttpStatusCode statusCode, String statusText, HttpHeaders headers, byte[] responseBody, Charset charset, HttpRequest request)

Constructor with a prepared message.

Method Summary

Modifier and TypeMethod and Description
private static HttpHeaders
copy(HttpHeaders headers)

Not all HttpHeaders implementations are serializable, so we make a copy to ensure that WebClientResponseException is.

public static WebClientResponseException
create(int statusCode, String statusText, HttpHeaders headers, byte[] body, Charset charset)

Create WebClientResponseException or an HTTP status specific subclass.

public static WebClientResponseException
create(int statusCode, String statusText, HttpHeaders headers, byte[] body, Charset charset, HttpRequest request)

Create WebClientResponseException or an HTTP status specific subclass.

public static WebClientResponseException
create(HttpStatusCode statusCode, String statusText, HttpHeaders headers, byte[] body, Charset charset, HttpRequest request)

Create WebClientResponseException or an HTTP status specific subclass.

private <E> E
public HttpHeaders
getHeaders()

Return the HTTP response headers.

public int
getRawStatusCode()
Deprecated since 6.0. as of 6.0, in favor of getStatusCode()

Return the raw HTTP status code value.

public HttpRequest
getRequest()

Return the corresponding request.

public <
the expected target type
E
>
E

Returns:

the decoded content, or null if there is no content
getResponseBodyAs
(Class<E>
the type to decode to
targetType
)

Decode the error content to the specified type.

public <E> E
public byte[]
getResponseBodyAsByteArray()

Return the response body as a byte array.

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 UTF-8.

public String
getResponseBodyAsString(Charset
the charset to use if the Content-Type of the response does not specify one.
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.

public HttpStatusCode
getStatusCode()

Return the HTTP status code value.

public String
getStatusText()

Return the HTTP status text.

private static String
initMessage(HttpStatusCode status, String reasonPhrase, HttpRequest request)

public void
setBodyDecodeFunction(Function<ResolvableType, ?>
the function to find a decoder with
decoderFunction
)

Provide a function to find a decoder the given target type.