类 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
Common base class for exceptions that contain actual HTTP response data.
- 从以下版本开始:
- 4.0
- 作者:
- Rossen Stoyanchev
- 另请参阅:
-
字段概要
字段修饰符和类型字段说明private Function<cn.taketoday.core.ResolvableType,?> private static final Charsetprivate final byte[]private final Stringprivate final HttpHeadersprivate static final longprivate final HttpStatusCodeprivate final String -
构造器概要
构造器构造器说明RestClientResponseException(String message, int statusCode, String statusText, HttpHeaders headers, byte[] responseBody, Charset responseCharset) Construct a new instance of with the given response data.RestClientResponseException(String message, HttpStatusCode statusCode, String statusText, HttpHeaders headers, byte[] responseBody, Charset responseCharset) Construct a new instance of with the given response data. -
方法概要
修饰符和类型方法说明intReturn the raw HTTP status code value.<E> EgetResponseBodyAs(cn.taketoday.core.ParameterizedTypeReference<E> targetType) Variant ofgetResponseBodyAs(Class)withParameterizedTypeReference.private <E> EgetResponseBodyAs(cn.taketoday.core.ResolvableType targetType) <E> EgetResponseBodyAs(Class<E> targetType) Convert the error response content to the specified type.byte[]Return the response body as a byte array.Return the response body converted to String.getResponseBodyAsString(Charset fallbackCharset) Return the response body converted to String.Return the HTTP response headers.Return the HTTP status code.Return the HTTP status text.voidsetBodyConvertFunction(Function<cn.taketoday.core.ResolvableType, ?> bodyConvertFunction) Provide a function to use to decode the response error content viagetResponseBodyAs(Class).从类继承的方法 cn.taketoday.core.NestedRuntimeException
contains, getMostSpecificCause, getNestedMessage, getRootCause
-
字段详细资料
-
serialVersionUID
private static final long serialVersionUID- 另请参阅:
-
DEFAULT_CHARSET
-
statusCode
-
statusText
-
responseBody
private final byte[] responseBody -
responseHeaders
-
responseCharset
-
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 valuestatusText- the status textheaders- the response headers (may benull)responseBody- the response body content (may benull)responseCharset- the response body charset (may benull)
-
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 valuestatusText- the status textheaders- the response headers (may benull)responseBody- the response body content (may benull)responseCharset- the response body charset (may benull)
-
-
方法详细资料
-
getStatusCode
Return the HTTP status code. -
getRawStatusCode
public int getRawStatusCode()Return the raw HTTP status code value. -
getStatusText
Return the HTTP status text. -
getResponseHeaders
Return the HTTP response headers. -
getResponseBodyAsByteArray
public byte[] getResponseBodyAsByteArray()Return the response body as a byte array. -
getResponseBodyAsString
Return the response body converted to String. The charset used is that of the response "Content-Type" or otherwise"UTF-8". -
getResponseBodyAsString
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
Convert the error response content to the specified type.- 类型参数:
E- the expected target type- 参数:
targetType- the type to convert to- 返回:
- the converted object, or
nullif there is no content
-
getResponseBodyAs
@Nullable public <E> E getResponseBodyAs(cn.taketoday.core.ParameterizedTypeReference<E> targetType) Variant ofgetResponseBodyAs(Class)withParameterizedTypeReference. -
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 viagetResponseBodyAs(Class).- 参数:
bodyConvertFunction- the function to use
-