ResponseErrorHandler interface.
This error handler checks for the status code on the
ClientHttpResponse. Any code in the 4xx or 5xx series is considered
to be an error. This behavior can be changed by overriding
hasError(HttpStatusCode). Unknown status codes will be ignored by
hasError(ClientHttpResponse).
See handleError(ClientHttpResponse) for more details on specific
exception types.
RestTemplate#setErrorHandler
| Modifier and Type | Field and Description |
|---|---|
| private List |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| protected Charset | Returns: the associated charset, ornull if nonethe response to inspect response)Determine the charset of the response (for inclusion in a status exception). |
| private String | getErrorMessage(int rawStatusCode, String statusText, byte[] responseBody, Charset charset)
Return error message with details from the response body. |
| protected byte[] | Returns: the response body as a byte array, or an empty byte array if the body could not be readthe response to inspect response)Read the body of the given response (for inclusion in a status exception). |
| public void | handleError(ClientHttpResponse
the response with the error response)Implements org. Handle the error in the given response with the given resolved status code. |
| protected void | handleError(ClientHttpResponse response, HttpStatusCode statusCode)
Handle the error based on the resolved status code. |
| public boolean | hasError(ClientHttpResponse
the response to inspect response)Implements org. Delegates to |
| protected boolean | Returns: true if the response indicates an error; false otherwisethe HTTP status code statusCode)Template method called from |
| protected boolean | Returns: true if the response indicates an error; false otherwisethe HTTP status code as raw value statusCode)
Deprecated
in favor of
hasError(HttpStatusCode)
Template method called from |
| protected Function | initBodyConvertFunction(ClientHttpResponse response, byte[] body)
Return a function for decoding the error content. |
| pack-priv void | setMessageConverters(List<HttpMessageConverter<?>> converters)
For internal use from the RestTemplate, to pass the message converters to use to decode error content. |
| messageConverters | back to summary |
|---|---|
| private List<HttpMessageConverter<?>> messageConverters
| |
| DefaultResponseErrorHandler | back to summary |
|---|---|
| public DefaultResponseErrorHandler() | |
| getCharset | back to summary |
|---|---|
| protected Charset getCharset(ClientHttpResponse response) Determine the charset of the response (for inclusion in a status exception).
| |
| getErrorMessage | back to summary |
|---|---|
| private String getErrorMessage(int rawStatusCode, String statusText, byte[] responseBody, Charset charset) Return error message with details from the response body. For example:
404 Not Found: [{'id': 123, 'message': 'my message'}]
| |
| getResponseBody | back to summary |
|---|---|
| protected byte[] getResponseBody(ClientHttpResponse response) Read the body of the given response (for inclusion in a status exception).
| |
| handleError | back to summary |
|---|---|
| public void handleError(ClientHttpResponse response) throws IOException Implements org. Handle the error in the given response with the given resolved status code. The default implementation throws:
| |
| handleError | back to summary |
|---|---|
| protected void handleError(ClientHttpResponse response, HttpStatusCode statusCode) throws IOException Handle the error based on the resolved status code. The default implementation delegates to
| |
| hasError | back to summary |
|---|---|
| public boolean hasError(ClientHttpResponse response) throws IOException Implements org. Delegates to
| |
| hasError | back to summary |
|---|---|
| protected boolean hasError(HttpStatusCode statusCode) Template method called from The default implementation checks
| |
| hasError | back to summary |
|---|---|
| protected boolean hasError(int statusCode)
Deprecated in favor of Template method called from The default implementation checks if the given status code is
| |
| initBodyConvertFunction | back to summary |
|---|---|
| protected Function Return a function for decoding the error content. This can be passed to
| |
| setMessageConverters | back to summary |
|---|---|
| pack-priv void setMessageConverters(List<HttpMessageConverter<?>> converters) For internal use from the RestTemplate, to pass the message converters to use to decode error content.
| |