类 WebClientResponseException

java.lang.Object
java.lang.Throwable
java.lang.Exception
java.lang.RuntimeException
cn.taketoday.core.NestedRuntimeException
cn.taketoday.web.reactive.function.client.WebClientException
cn.taketoday.web.reactive.function.client.WebClientResponseException
所有已实现的接口:
Serializable
直接已知子类:
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.
从以下版本开始:
4.0
作者:
Arjen Poutsma
另请参阅:
  • 字段详细资料

    • serialVersionUID

      private static final long serialVersionUID
      另请参阅:
    • statusCode

      private final HttpStatusCode statusCode
    • statusText

      private final String statusText
    • responseBody

      private final byte[] responseBody
    • headers

      private final HttpHeaders headers
    • responseCharset

      @Nullable private final Charset responseCharset
    • request

      @Nullable private final HttpRequest request
    • bodyDecodeFunction

      @Nullable private Function<cn.taketoday.core.ResolvableType,?> bodyDecodeFunction
  • 构造器详细资料

    • WebClientResponseException

      public WebClientResponseException(int statusCode, String statusText, @Nullable HttpHeaders headers, @Nullable byte[] body, @Nullable Charset charset)
      Constructor with response data only, and a default message.
    • WebClientResponseException

      public 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.
    • WebClientResponseException

      public 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.
    • WebClientResponseException

      public WebClientResponseException(String message, int statusCode, String statusText, @Nullable HttpHeaders headers, @Nullable byte[] responseBody, @Nullable Charset charset)
      Constructor with a prepared message.
    • WebClientResponseException

      public WebClientResponseException(String message, int statusCode, String statusText, @Nullable HttpHeaders headers, @Nullable byte[] responseBody, @Nullable Charset charset, @Nullable HttpRequest request)
      Constructor with a prepared message.
    • WebClientResponseException

      public WebClientResponseException(String message, HttpStatusCode statusCode, String statusText, @Nullable HttpHeaders headers, @Nullable byte[] responseBody, @Nullable Charset charset, @Nullable HttpRequest request)
      Constructor with a prepared message.
  • 方法详细资料

    • initMessage

      private static String initMessage(HttpStatusCode status, String reasonPhrase, @Nullable HttpRequest request)
    • getStatusCode

      public HttpStatusCode getStatusCode()
      Return the HTTP status code value.
      抛出:
      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 UTF-8. 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.
      参数:
      defaultCharset - the charset to use if the Content-Type of the response does not specify one.
    • getResponseBodyAs

      @Nullable public <E> E getResponseBodyAs(Class<E> targetType)
      Decode the error content to the specified type.
      类型参数:
      E - the expected target type
      参数:
      targetType - the type to decode to
      返回:
      the decoded content, or null if there is no content
      抛出:
      IllegalStateException - if a Decoder cannot be found
      cn.taketoday.core.codec.DecodingException - if decoding fails
    • getResponseBodyAs

      @Nullable public <E> E getResponseBodyAs(cn.taketoday.core.ParameterizedTypeReference<E> targetType)
      Variant of getResponseBodyAs(Class) with ParameterizedTypeReference.
    • decodeBody

      @Nullable private <E> E decodeBody(cn.taketoday.core.ResolvableType targetType)
    • getRequest

      @Nullable public HttpRequest getRequest()
      Return the corresponding request.
    • setBodyDecodeFunction

      public void setBodyDecodeFunction(Function<cn.taketoday.core.ResolvableType,?> decoderFunction)
      Provide a function to find a decoder the given target type. For use with getResponseBodyAs(Class).
      参数:
      decoderFunction - the function to find a decoder with
    • create

      public static WebClientResponseException create(int statusCode, String statusText, HttpHeaders headers, byte[] body, @Nullable Charset charset)
      Create WebClientResponseException or an HTTP status specific subclass.
    • 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.
    • create

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