Class TwitterErrorHandler

  extended by org.springframework.web.client.DefaultResponseErrorHandler
      extended by
All Implemented Interfaces:

public class TwitterErrorHandler
extends DefaultResponseErrorHandler

Subclass of DefaultResponseErrorHandler that allows some client and server exceptions to flow through RestTemplate as non-errors. By default, RestTemplate interprets HTTP client (4xx series) errors and server (5xx series) errors as exceptions and throws an HttpClientErrorException. In doing so, this prevents the caller from retrieving the body of the response. When Twitter returns an error, it places some extra information about that error in the body of the response. In order to allow TwitterTemplate to read that information, those errors need to be treated as non-errors by RestTemplate. This puts the burden on TwitterTemplate to interpret the error and act accordingly. But it also enables TwitterTemplate to obtain more information about the nature of the error.

Constructor Summary
Method Summary
 boolean hasError(ClientHttpResponse response)
Methods inherited from class org.springframework.web.client.DefaultResponseErrorHandler
handleError, hasError
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Detail


public TwitterErrorHandler()
Method Detail


public boolean hasError(ClientHttpResponse response)
Specified by:
hasError in interface ResponseErrorHandler
hasError in class DefaultResponseErrorHandler