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