public static void handleErrorWithRedirect(HttpResponse response) throws SocialClientLibException, RedirectException {
int statusCode = response.getStatusLine().getStatusCode();
if (statusCode != 200) {
if(statusCode == 404){
throw new SocialClientLibException(response.getStatusLine().toString(), new NotFoundException());
} else if(statusCode == 403){
throw new SocialClientLibException(response.getStatusLine().toString(), new AccessDeniedException());
} else if(statusCode == 401){
throw new SocialClientLibException(response.getStatusLine().toString(), new UnAuthenticatedException());
} else if (statusCode == 301) {
/** handle redirect */
Header[] headers = response.getHeaders("Location");
if (headers != null && headers.length != 0) {
String newUrl = headers[headers.length - 1].getValue();