类 RestClientResponseException

java.lang.Object
java.lang.Throwable
java.lang.Exception
java.lang.RuntimeException
cn.taketoday.core.NestedRuntimeException
cn.taketoday.web.client.RestClientException
cn.taketoday.web.client.RestClientResponseException
所有已实现的接口:
Serializable
直接已知子类:
HttpStatusCodeException, UnknownHttpStatusCodeException

public class RestClientResponseException extends RestClientException
Common base class for exceptions that contain actual HTTP response data.
从以下版本开始:
4.0
作者:
Rossen Stoyanchev
另请参阅:
  • 字段详细资料

    • serialVersionUID

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

      private static final Charset DEFAULT_CHARSET
    • statusCode

      private final HttpStatusCode statusCode
    • statusText

      private final String statusText
    • responseBody

      private final byte[] responseBody
    • responseHeaders

      @Nullable private final HttpHeaders responseHeaders
    • responseCharset

      @Nullable private final String responseCharset
    • bodyConvertFunction

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

    • RestClientResponseException

      public RestClientResponseException(String message, int statusCode, String statusText, @Nullable HttpHeaders headers, @Nullable byte[] responseBody, @Nullable Charset responseCharset)
      Construct a new instance of with the given response data.
      参数:
      statusCode - the raw status code value
      statusText - the status text
      headers - the response headers (may be null)
      responseBody - the response body content (may be null)
      responseCharset - the response body charset (may be null)
    • RestClientResponseException

      public RestClientResponseException(String message, HttpStatusCode statusCode, String statusText, @Nullable HttpHeaders headers, @Nullable byte[] responseBody, @Nullable Charset responseCharset)
      Construct a new instance of with the given response data.
      参数:
      statusCode - the raw status code value
      statusText - the status text
      headers - the response headers (may be null)
      responseBody - the response body content (may be null)
      responseCharset - the response body charset (may be null)
  • 方法详细资料

    • getStatusCode

      public HttpStatusCode getStatusCode()
      Return the HTTP status code.
    • getRawStatusCode

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

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

      @Nullable public HttpHeaders getResponseHeaders()
      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 converted to String. The charset used is that of the response "Content-Type" or otherwise "UTF-8".
    • getResponseBodyAsString

      public String getResponseBodyAsString(Charset fallbackCharset)
      Return the response body converted to String. The charset used is that of the response "Content-Type" or otherwise the one given.
      参数:
      fallbackCharset - the charset to use on if the response doesn't specify.
    • getResponseBodyAs

      @Nullable public <E> E getResponseBodyAs(Class<E> targetType)
      Convert the error response content to the specified type.
      类型参数:
      E - the expected target type
      参数:
      targetType - the type to convert to
      返回:
      the converted object, or null if there is no content
    • getResponseBodyAs

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

      @Nullable private <E> E getResponseBodyAs(cn.taketoday.core.ResolvableType targetType)
    • setBodyConvertFunction

      public void setBodyConvertFunction(Function<cn.taketoday.core.ResolvableType,?> bodyConvertFunction)
      Provide a function to use to decode the response error content via getResponseBodyAs(Class).
      参数:
      bodyConvertFunction - the function to use