public class

DefaultResponseErrorHandler

extends Object
implements ResponseErrorHandler
java.lang.Object
   ↳ org.springframework.web.client.DefaultResponseErrorHandler

Class Overview

Default implementation of the ResponseErrorHandler interface.

This error handler checks for the status code on the ClientHttpResponse: any code with series CLIENT_ERROR or SERVER_ERROR is considered to be an error. This behavior can be changed by overriding the hasError(HttpStatus) method.

Summary

Public Constructors
DefaultResponseErrorHandler()
Public Methods
void handleError(ClientHttpResponse response)
Handles the error in the given response.

The default implementation throws a HttpClientErrorException if the response status code is CLIENT_ERROR, a HttpServerErrorException if it is SERVER_ERROR, and a RestClientException in other cases.

boolean hasError(ClientHttpResponse response)
Delegates to hasError(HttpStatus) with the response status code.
Protected Methods
boolean hasError(HttpStatus statusCode)
Template method called from hasError(ClientHttpResponse).
[Expand]
Inherited Methods
From class java.lang.Object
From interface org.springframework.web.client.ResponseErrorHandler

Public Constructors

public DefaultResponseErrorHandler ()

Public Methods

public void handleError (ClientHttpResponse response)

Handles the error in the given response. This method is only called when hasError(ClientHttpResponse) has returned true.

The default implementation throws a HttpClientErrorException if the response status code is CLIENT_ERROR, a HttpServerErrorException if it is SERVER_ERROR, and a RestClientException in other cases.

Parameters
response the response with the error
Throws
IOException

public boolean hasError (ClientHttpResponse response)

Delegates to hasError(HttpStatus) with the response status code.

Parameters
response the response to inspect
Returns
  • true if the response has an error; false otherwise
Throws
IOException

Protected Methods

protected boolean hasError (HttpStatus statusCode)

Template method called from hasError(ClientHttpResponse).

The default implementation checks if the given status code is CLIENT_ERROR or SERVER_ERROR. Can be overridden in subclasses.

Parameters
statusCode the HTTP status code
Returns
  • true if the response has an error; false otherwise