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
Exceptions that contain actual HTTP response data.
- Since:
- 5.0
- Author:
- Arjen Poutsma, Sebastien Deleuze
- See Also:
- 
Nested Class SummaryNested ClassesModifier and TypeClassDescriptionstatic classWebClientResponseExceptionfor HTTP status 502 Bad Gateway.static classWebClientResponseExceptionfor status HTTP 400 Bad Request.static classWebClientResponseExceptionfor status HTTP 409 Conflict.static classWebClientResponseExceptionfor status HTTP 403 Forbidden.static classWebClientResponseExceptionfor status HTTP 504 Gateway Timeout.static classWebClientResponseExceptionfor status HTTP 410 Gone.static classWebClientResponseExceptionfor status HTTP 500 Internal Server Error.static classWebClientResponseExceptionfor status HTTP 405 Method Not Allowed.static classWebClientResponseExceptionfor status HTTP 406 Not Acceptable.static classWebClientResponseExceptionfor status HTTP 404 Not Found.static classWebClientResponseExceptionfor status HTTP 501 Not Implemented.static classWebClientResponseExceptionfor status HTTP 503 Service Unavailable.static classWebClientResponseExceptionfor status HTTP 429 Too Many Requests.static classWebClientResponseExceptionfor status HTTP 401 Unauthorized.static classWebClientResponseExceptionfor status HTTP 422 Unprocessable Entity.static classWebClientResponseExceptionfor status HTTP 415 Unsupported Media Type.
- 
Constructor SummaryConstructorsConstructorDescriptionWebClientResponseException(int statusCode, String statusText, HttpHeaders headers, byte[] body, Charset charset) Constructor with response data only, and a default message.WebClientResponseException(int status, String reasonPhrase, HttpHeaders headers, byte[] body, Charset charset, HttpRequest request) Constructor with response data only, and a default message.WebClientResponseException(String message, int statusCode, String statusText, HttpHeaders headers, byte[] responseBody, Charset charset) Constructor with a prepared message.WebClientResponseException(String message, int statusCode, String statusText, HttpHeaders headers, byte[] responseBody, Charset charset, HttpRequest request) Constructor with a prepared message.WebClientResponseException(String message, HttpStatusCode statusCode, String statusText, HttpHeaders headers, byte[] responseBody, Charset charset, HttpRequest request) Constructor with a prepared message.WebClientResponseException(HttpStatusCode statusCode, String reasonPhrase, HttpHeaders headers, byte[] body, Charset charset, HttpRequest request) Constructor with response data only, and a default message.
- 
Method SummaryModifier and TypeMethodDescriptionstatic WebClientResponseExceptioncreate(int statusCode, String statusText, HttpHeaders headers, byte[] body, Charset charset) CreateWebClientResponseExceptionor an HTTP status specific subclass.static WebClientResponseExceptioncreate(int statusCode, String statusText, HttpHeaders headers, byte[] body, Charset charset, HttpRequest request) CreateWebClientResponseExceptionor an HTTP status specific subclass.static WebClientResponseExceptioncreate(HttpStatusCode statusCode, String statusText, HttpHeaders headers, byte[] body, Charset charset, HttpRequest request) CreateWebClientResponseExceptionor an HTTP status specific subclass.Return the HTTP response headers.intDeprecated.Return the corresponding request.<E> EgetResponseBodyAs(Class<E> targetType) Decode the error content to the specified type.<E> EgetResponseBodyAs(ParameterizedTypeReference<E> targetType) Variant ofgetResponseBodyAs(Class)withParameterizedTypeReference.byte[]Return the response body as a byte array.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.getResponseBodyAsString(Charset defaultCharset) Variant ofgetResponseBodyAsString()that allows specifying the charset to fall back on, if a charset is not available from the media type for the response.Return the HTTP status code value.Return the HTTP status text.voidsetBodyDecodeFunction(Function<ResolvableType, ?> decoderFunction) Provide a function to find a decoder the given target type.Methods inherited from class org.springframework.core.NestedRuntimeExceptioncontains, getMostSpecificCause, getRootCauseMethods inherited from class java.lang.ThrowableaddSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString
- 
Constructor Details- 
WebClientResponseExceptionpublic WebClientResponseException(int statusCode, String statusText, @Nullable HttpHeaders headers, @Nullable byte[] body, @Nullable Charset charset) Constructor with response data only, and a default message.- Since:
- 5.1
 
- 
WebClientResponseExceptionpublic WebClientResponseException(int status, String reasonPhrase, @Nullable HttpHeaders headers, @Nullable byte[] body, @Nullable Charset charset, @Nullable HttpRequest request) Constructor with response data only, and a default message.- Since:
- 5.1.4
 
- 
WebClientResponseExceptionpublic WebClientResponseException(HttpStatusCode statusCode, String reasonPhrase, @Nullable HttpHeaders headers, @Nullable byte[] body, @Nullable Charset charset, @Nullable HttpRequest request) Constructor with response data only, and a default message.- Since:
- 6.0
 
- 
WebClientResponseExceptionpublic WebClientResponseException(String message, int statusCode, String statusText, @Nullable HttpHeaders headers, @Nullable byte[] responseBody, @Nullable Charset charset) Constructor with a prepared message.
- 
WebClientResponseExceptionpublic WebClientResponseException(String message, int statusCode, String statusText, @Nullable HttpHeaders headers, @Nullable byte[] responseBody, @Nullable Charset charset, @Nullable HttpRequest request) Constructor with a prepared message.- Since:
- 5.1.4
 
- 
WebClientResponseExceptionpublic WebClientResponseException(String message, HttpStatusCode statusCode, String statusText, @Nullable HttpHeaders headers, @Nullable byte[] responseBody, @Nullable Charset charset, @Nullable HttpRequest request) Constructor with a prepared message.- Since:
- 6.0
 
 
- 
- 
Method Details- 
getStatusCodeReturn the HTTP status code value.- Throws:
- IllegalArgumentException- in case of an unknown HTTP status code
 
- 
getRawStatusCodeDeprecated.in favor ofgetStatusCode(), for removal in 7.0Return the raw HTTP status code value.
- 
getStatusTextReturn the HTTP status text.
- 
getHeadersReturn the HTTP response headers.
- 
getResponseBodyAsByteArraypublic byte[] getResponseBodyAsByteArray()Return the response body as a byte array.
- 
getResponseBodyAsStringReturn the response content as a String using the charset of media type for the response, if available, or otherwise falling back on UTF-8. UsegetResponseBodyAsString(Charset)if you want to fall back on a different, default charset.
- 
getResponseBodyAsStringVariant ofgetResponseBodyAsString()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
 
- 
getResponseBodyAsDecode the error content to the specified type.- Type Parameters:
- E- the expected target type
- Parameters:
- targetType- the type to decode to
- Returns:
- the decoded content, or nullif there is no content
- Throws:
- IllegalStateException- if a Decoder cannot be found
- DecodingException- if decoding fails
- Since:
- 6.0
 
- 
getResponseBodyAsVariant ofgetResponseBodyAs(Class)withParameterizedTypeReference.- Since:
- 6.0
 
- 
getRequestReturn the corresponding request.- Since:
- 5.1.4
 
- 
setBodyDecodeFunctionProvide a function to find a decoder the given target type. For use withgetResponseBodyAs(Class).- Parameters:
- decoderFunction- the function to find a decoder with
- Since:
- 6.0
 
- 
getMessage- Overrides:
- getMessagein class- Throwable
 
- 
createpublic static WebClientResponseException create(int statusCode, String statusText, HttpHeaders headers, byte[] body, @Nullable Charset charset) CreateWebClientResponseExceptionor an HTTP status specific subclass.- Since:
- 5.1
 
- 
createpublic static WebClientResponseException create(int statusCode, String statusText, HttpHeaders headers, byte[] body, @Nullable Charset charset, @Nullable HttpRequest request) CreateWebClientResponseExceptionor an HTTP status specific subclass.- Since:
- 5.1.4
 
- 
createpublic static WebClientResponseException create(HttpStatusCode statusCode, String statusText, HttpHeaders headers, byte[] body, @Nullable Charset charset, @Nullable HttpRequest request) CreateWebClientResponseExceptionor an HTTP status specific subclass.- Since:
- 6.0
 
 
- 
getStatusCode(), for removal in 7.0