From e90955777d96c9aa0f7f6827d13bbaae87075f06 Mon Sep 17 00:00:00 2001 From: Kai Moritz Date: Sat, 7 Nov 2015 20:04:10 +0100 Subject: [PATCH] Implemented new exception CallbackVerificationFailedException --- .../CallbackVerificationFailedException.java | 14 ++++++++++++ .../exceptions/GraphApiException.java | 1 + .../client/GraphApiErrorHandlerTest.java | 22 +++++++++++++++++++ 3 files changed, 37 insertions(+) create mode 100644 src/main/java/de/juplo/facebook/exceptions/CallbackVerificationFailedException.java diff --git a/src/main/java/de/juplo/facebook/exceptions/CallbackVerificationFailedException.java b/src/main/java/de/juplo/facebook/exceptions/CallbackVerificationFailedException.java new file mode 100644 index 0000000..5951471 --- /dev/null +++ b/src/main/java/de/juplo/facebook/exceptions/CallbackVerificationFailedException.java @@ -0,0 +1,14 @@ +package de.juplo.facebook.exceptions; + + +/** + * 2200: Callback verification failed. + * @author Kai Moritz + */ +public class CallbackVerificationFailedException extends OAuthException +{ + protected CallbackVerificationFailedException(FacebookErrorMessage error) + { + super(error); + } +} diff --git a/src/main/java/de/juplo/facebook/exceptions/GraphApiException.java b/src/main/java/de/juplo/facebook/exceptions/GraphApiException.java index 807c8b3..705caa4 100644 --- a/src/main/java/de/juplo/facebook/exceptions/GraphApiException.java +++ b/src/main/java/de/juplo/facebook/exceptions/GraphApiException.java @@ -80,6 +80,7 @@ public class GraphApiException extends OAuth2Exception // 950..999: batch api errors // 1000..1099: event api errors // 1100..1199: live-message errors + case 2200: return new CallbackVerificationFailedException(error); default: LOG.info("unmapped error: {}", error); diff --git a/src/test/java/de/juplo/facebook/client/GraphApiErrorHandlerTest.java b/src/test/java/de/juplo/facebook/client/GraphApiErrorHandlerTest.java index 3917404..f0c26e9 100644 --- a/src/test/java/de/juplo/facebook/client/GraphApiErrorHandlerTest.java +++ b/src/test/java/de/juplo/facebook/client/GraphApiErrorHandlerTest.java @@ -1,6 +1,7 @@ package de.juplo.facebook.client; import de.juplo.facebook.exceptions.AccessTokenRequiredException; +import de.juplo.facebook.exceptions.CallbackVerificationFailedException; import de.juplo.facebook.exceptions.UnsupportedGetRequestException; import de.juplo.facebook.exceptions.UnexpectedErrorException; import de.juplo.facebook.exceptions.RateExceededException; @@ -234,6 +235,27 @@ public class GraphApiErrorHandlerTest } } + @Test + public void testError2200() + { + requestFactory.setBody("{\"error\":{\"message\":\"(#2200) callback verification failed: \",\"type\":\"OAuthException\",\"code\":2200,\"fbtrace_id\":\"ESLjoZKvPXg\"}}"); + + try + { + clientTemplate.getForObject("ANY", SOME.class); + fail("The expected exception was not thrown"); + } + catch(CallbackVerificationFailedException e) + { + log.debug("{}", e.toString()); + assertEquals("invalid_request", e.getOAuth2ErrorCode()); + assertEquals(new Integer(2200), e.getCode()); + assertEquals("(#2200) callback verification failed: ", e.getMessage()); + assertEquals(Type.OAuthException, e.getType()); + assertEquals("ESLjoZKvPXg", e.getTraceId()); + } + } + @Test public void testUnmappedError() { -- 2.20.1