public void handleError(ClientHttpResponse response) throws IOException {

    // first try: www-authenticate error
    List<String> authenticateHeaders = response.getHeaders().get("WWW-Authenticate");
    if (authenticateHeaders != null) {
      for (String authenticateHeader : authenticateHeaders) {
        maybeThrowExceptionFromHeader(authenticateHeader, OAuth2AccessToken.BEARER_TYPE);
        maybeThrowExceptionFromHeader(authenticateHeader, OAuth2AccessToken.OAUTH2_TYPE);
      }
    }

    // then delegate to the custom handler
    errorHandler.handleError(response);
  }
 public boolean hasError(ClientHttpResponse response) throws IOException {
   return errorHandler.hasError(response);
 }