接口 ResponseErrorHandler
public interface ResponseErrorHandler
Strategy interface used by the
RestTemplate to determine
whether a particular response has an error or not.- 从以下版本开始:
- 4.0
- 作者:
- Arjen Poutsma
-
方法概要
修饰符和类型方法说明voidhandleError(ClientHttpResponse response) Handle the error in the given response.default voidhandleError(URI url, HttpMethod method, ClientHttpResponse response) Alternative tohandleError(ClientHttpResponse)with extra information providing access to the request URL and HTTP method.booleanhasError(ClientHttpResponse response) Indicate whether the given response has any errors.
-
方法详细资料
-
hasError
Indicate whether the given response has any errors.Implementations will typically inspect the
HttpStatusof the response.- 参数:
response- the response to inspect- 返回:
trueif the response indicates an error;falseotherwise- 抛出:
IOException- in case of I/O errors
-
handleError
Handle the error in the given response.This method is only called when
hasError(ClientHttpResponse)has returnedtrue.- 参数:
response- the response with the error- 抛出:
IOException- in case of I/O errors
-
handleError
default void handleError(URI url, HttpMethod method, ClientHttpResponse response) throws IOException Alternative tohandleError(ClientHttpResponse)with extra information providing access to the request URL and HTTP method.- 参数:
url- the request URLmethod- the HTTP methodresponse- the response with the error- 抛出:
IOException- in case of I/O errors
-