X-Git-Url: https://juplo.de/gitweb/?p=facebook-errors;a=blobdiff_plain;f=src%2Fmain%2Fjava%2Fde%2Fjuplo%2Ffacebook%2Ferrors%2FGraphApiErrorResponseErrorHandler.java;h=41f00fe93ef255a6ebad61506ca7d809274a79e8;hp=123c7f3d6a696bae2a3c23c2681b4006954ec774;hb=1c809f83874d51c696721f265115ee11f99e607a;hpb=8079d646addc5206f64bfb213d018a2fa94444d3 diff --git a/src/main/java/de/juplo/facebook/errors/GraphApiErrorResponseErrorHandler.java b/src/main/java/de/juplo/facebook/errors/GraphApiErrorResponseErrorHandler.java index 123c7f3..41f00fe 100644 --- a/src/main/java/de/juplo/facebook/errors/GraphApiErrorResponseErrorHandler.java +++ b/src/main/java/de/juplo/facebook/errors/GraphApiErrorResponseErrorHandler.java @@ -87,24 +87,17 @@ public class GraphApiErrorResponseErrorHandler implements ResponseErrorHandler final byte[] body = FileCopyUtils.copyToByteArray(response.getBody()); GraphApiException error; - try + error = GraphApiException.create(response.getStatusCode(), response.getHeaders(), body); + if (LOG.isInfoEnabled()) + LOG.info("error-response: {}", new String(body, Charset.forName("UTF-8"))); + if (!error.getClass().equals(ErrorResponseParsingErrorException.class)) { - error = GraphApiException.create(response.getStatusCode(), response.getHeaders(), body); - if (LOG.isInfoEnabled()) - LOG.info("error-response: {}", new String(body, Charset.forName("UTF-8"))); + throw error; } - catch (Exception e) + else { // 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: 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 ClientHttpResponse buffered = new ClientHttpResponse() @@ -149,7 +142,5 @@ public class GraphApiErrorResponseErrorHandler implements ResponseErrorHandler parent.handleError(buffered); return; } - - throw error; } }