Implemented new exception CallbackVerificationFailedException
authorKai Moritz <kai@juplo.de>
Sat, 7 Nov 2015 19:04:10 +0000 (20:04 +0100)
committerKai Moritz <kai@juplo.de>
Tue, 10 Nov 2015 14:51:19 +0000 (15:51 +0100)
src/main/java/de/juplo/facebook/exceptions/CallbackVerificationFailedException.java [new file with mode: 0644]
src/main/java/de/juplo/facebook/exceptions/GraphApiException.java
src/test/java/de/juplo/facebook/client/GraphApiErrorHandlerTest.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 (file)
index 0000000..5951471
--- /dev/null
@@ -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);
+  }
+}
index 807c8b3..705caa4 100644 (file)
@@ -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);
index 3917404..f0c26e9 100644 (file)
@@ -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()
   {