X-Git-Url: https://juplo.de/gitweb/?a=blobdiff_plain;f=src%2Fmain%2Fjava%2Fde%2Fjuplo%2Ffacebook%2Ferrors%2FGraphApiErrorHandler.java;h=265f1455c8a87c428b31f93ba5e115209aa79e1d;hb=4fda7c67e6efd4f80e7437c75c76dbeb56f404c7;hp=13a93e8ff66fd84570bf0d160bee1f2482fb977b;hpb=89065da8bbd59c4973d837c10cf63d967f6357cc;p=facebook-errors diff --git a/src/main/java/de/juplo/facebook/errors/GraphApiErrorHandler.java b/src/main/java/de/juplo/facebook/errors/GraphApiErrorHandler.java index 13a93e8..265f145 100644 --- a/src/main/java/de/juplo/facebook/errors/GraphApiErrorHandler.java +++ b/src/main/java/de/juplo/facebook/errors/GraphApiErrorHandler.java @@ -57,15 +57,16 @@ public class GraphApiErrorHandler implements ResponseErrorHandler @Override public void handleError(final ClientHttpResponse response) throws IOException { - if (!HttpStatus.BAD_REQUEST.equals(response.getStatusCode())) - { - // We will only handle 400 BAD REQUEST - LOG.debug("ignoring response with status-code {}.", response.getStatusCode()); - parent.handleError(response); - return; - } - + GraphApiErrorHandler.handleError(parent, response); + } + 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 @@ -79,7 +80,7 @@ public class GraphApiErrorHandler implements ResponseErrorHandler try { - error = GraphApiException.create(body); + error = GraphApiException.create(response.getStatusCode(), response.getHeaders(), body); if (LOG.isInfoEnabled()) LOG.info("error-response: {}", new String(body, Charset.forName("UTF-8"))); } @@ -88,7 +89,12 @@ public class GraphApiErrorHandler implements ResponseErrorHandler // The body of the HTTP-message could not be parsed. // Let the parent error-handler try to handle the response. - LOG.warn("Could not convert the response into an exception, because the body is unparsable: {}", body); + LOG.warn( + "Could not convert the response into an exception, " + + "because the body is unparsable: error={}, body={}", + e.toString(), + new String(body, Charset.forName("UTF-8")) + ); // To do so, we have to wrap the original response to fill in // the buffered body, if needed