Added error 613: rate exceeded
authorKai Moritz <kai@juplo.de>
Tue, 29 Jul 2014 12:03:51 +0000 (14:03 +0200)
committerKai Moritz <kai@juplo.de>
Tue, 6 Oct 2015 06:22:25 +0000 (08:22 +0200)
src/main/java/de/juplo/facebook/GraphApiExceptionJackson1Deserializer.java
src/main/java/de/juplo/facebook/GraphApiExceptionJackson2Deserializer.java
src/main/java/de/juplo/facebook/RateExceededException.java [new file with mode: 0644]
src/test/java/de/juplo/facebook/GraphApiErrorHandlerTest.java

index 2d0c002..8a1d3bf 100644 (file)
@@ -87,6 +87,7 @@ public class GraphApiExceptionJackson1Deserializer
       case 2:   return new UnexpectedErrorException();
       case 21:  return new PageMigratedException(message);
       case 100: return new UnsupportedGetRequestException();
+      case 613: return new RateExceededException();
       default:  return new GraphApiException(message, type, code);
     }
   }
index ec46de3..becb51f 100644 (file)
@@ -94,6 +94,7 @@ public class GraphApiExceptionJackson2Deserializer
       case 2:   return new UnexpectedErrorException();
       case 21:  return new PageMigratedException(message);
       case 100: return new UnsupportedGetRequestException();
+      case 613: return new RateExceededException();
       default:  return new GraphApiException(message, type, code);
     }
   }
diff --git a/src/main/java/de/juplo/facebook/RateExceededException.java b/src/main/java/de/juplo/facebook/RateExceededException.java
new file mode 100644 (file)
index 0000000..b633069
--- /dev/null
@@ -0,0 +1,14 @@
+package de.juplo.facebook;
+
+
+/**
+ *
+ * @author kai
+ */
+public class RateExceededException extends OAuthException
+{
+  public RateExceededException()
+  {
+    super("(#613) Calls to stream have exceeded the rate of 600 calls per 600 seconds.", 613);
+  }
+}
index b9dc905..d93121b 100644 (file)
@@ -173,6 +173,37 @@ public class GraphApiErrorHandlerTest
     }
   }
 
+  @Test
+  public void testError613()
+  {
+    log.info("testError613");
+
+
+    requestFactory.setBody(
+        "{\n" +
+        "  \"error\":\n" +
+        "  {\n" +
+        "    \"message\": \"(#613) Calls to stream have exceeded the rate of 600 calls per 600 seconds.\",\n" +
+        "    \"type\": \"OAuthException\",\n" +
+        "    \"code\": 613\n" +
+        "  }\n" +
+        "}");
+
+    try
+    {
+      clientTemplate.getForObject("ANY", SOME.class);
+      fail("The expected exception was not thrown");
+    }
+    catch(RateExceededException e)
+    {
+      log.debug("{}", e.toString());
+      assertEquals("invalid_request", e.getOAuth2ErrorCode());
+      assertEquals(613, e.getCode());
+      assertEquals("(#613) Calls to stream have exceeded the rate of 600 calls per 600 seconds.", e.getMessage());
+      assertEquals("OAuthException", e.getType());
+    }
+  }
+
   @Test
   public void testUnmappedError()
   {