Fixed bug / refined GraphApiErrorResponseErrorHandler
[facebook-errors] / src / main / java / de / juplo / facebook / errors / GraphApiErrorResponseErrorHandler.java
index 41f00fe..9df86a9 100644 (file)
@@ -55,27 +55,26 @@ public class GraphApiErrorResponseErrorHandler implements ResponseErrorHandler
   }
 
 
+  private boolean hasGraphApiError(ClientHttpResponse response) throws IOException
+  {
+    return HttpStatus.Series.CLIENT_ERROR.equals(response.getStatusCode().series());
+  }
+
   @Override
   public boolean hasError(ClientHttpResponse response) throws IOException
   {
-    return
-        HttpStatus.Series.CLIENT_ERROR.equals(response.getStatusCode().series())
-        || this.parent.hasError(response);
+    return hasGraphApiError(response) || parent.hasError(response);
   }
 
   @Override
   public void handleError(final ClientHttpResponse response) throws IOException
   {
-    GraphApiErrorResponseErrorHandler.handleError(parent, response);
-  }
+    if (!hasGraphApiError(response))
+    {
+      parent.handleError(response);
+      return;
+    }
 
-  public static void handleError(
-      final ResponseErrorHandler parent,
-      final ClientHttpResponse response
-      )
-      throws
-        IOException
-  {
     if (response.getBody() == null)
     {
       // There is no body to interpret in the HTTP-message