package org.springframework.social.twitter;

import java.io.IOException;

import org.springframework.http.HttpStatus;
import org.springframework.http.client.ClientHttpResponse;
import org.springframework.web.client.DefaultResponseErrorHandler;

public class TwitterErrorHandler extends DefaultResponseErrorHandler {

	// TODO: This is targeting a specific issue at the moment. I will probably
	// want to revisit this error handler to better address other Twitter errors
	// or even create a more generic error handler that can be used with the
	// other social networks.
	public boolean hasError(ClientHttpResponse response) throws IOException {
		if (response.getStatusCode().equals(HttpStatus.FORBIDDEN)) {
			return false;
		}
		return super.hasError(response);
	}

}

@@ -65,16 +65,64 @@
 ception;
+%0Aimport java.util.Arrays;%0Aimport java.util.List;
 %0A%0Aimport
@@ -357,17 +357,126 @@
 ndler %7B%0A
+%09private static List%3CHttpStatus%3E NOT_ERRORS = Arrays.asList(HttpStatus.FORBIDDEN, HttpStatus.UNAUTHORIZED);%0A%09
 %0A
-
 %09// TODO
@@ -802,16 +802,36 @@
  %7B%0A%09%09if 
+(NOT_ERRORS.contains
 (respons
@@ -851,36 +851,8 @@
 de()
-.equals(HttpStatus.FORBIDDEN
 )) %7B
@@ -873,12 +873,13 @@
 se;%0A
-
 %09%09%7D%0A
+%0A
 %09%09re

Change response error handler to not treat 401 Forbidden responses as errors. That way they flow through RestTemplate and I handle them as non-exceptional cases.