Added an exception for error 12: X field is deprecated vor version vY.Z and higher
authorKai Moritz <kai@juplo.de>
Tue, 23 Aug 2016 18:26:17 +0000 (20:26 +0200)
committerKai Moritz <kai@jupl.de>
Fri, 22 Nov 2019 06:29:43 +0000 (07:29 +0100)
pom.xml
src/main/java/de/juplo/facebook/errors/DeprecatedException.java [new file with mode: 0644]
src/main/java/de/juplo/facebook/errors/GraphApiException.java
src/main/resources/META-INF/spring.factories
src/test/java/de/juplo/facebook/errors/GraphApiErrorHandlerTest.java

diff --git a/pom.xml b/pom.xml
index ed54930..42f2841 100644 (file)
--- a/pom.xml
+++ b/pom.xml
@@ -5,7 +5,7 @@
   <parent>
     <groupId>org.springframework.boot</groupId>
     <artifactId>spring-boot-starter-parent</artifactId>
-    <version>1.3.5.RELEASE</version>
+    <version>1.3.7.RELEASE</version>
   </parent>
 
 
diff --git a/src/main/java/de/juplo/facebook/errors/DeprecatedException.java b/src/main/java/de/juplo/facebook/errors/DeprecatedException.java
new file mode 100644 (file)
index 0000000..8274cb6
--- /dev/null
@@ -0,0 +1,16 @@
+package de.juplo.facebook.errors;
+
+
+
+/**
+ * 12: XYZ field is deprecated for versions vZ.Z and higher
+ * @author Kai Moritz
+ * @see https://developers.facebook.com/docs/graph-api/using-graph-api/#errors
+ */
+public class DeprecatedException extends OAuthException
+{
+  protected DeprecatedException(FacebookErrorMessage error)
+  {
+    super(error);
+  }
+}
index 9558b9d..53f075e 100644 (file)
@@ -67,6 +67,7 @@ public class GraphApiException extends RuntimeException
       case 2:     return new UnexpectedErrorException(error);
       case 4:     return new TooManyAppCallsException(error);
       case 10:    return new AuthorizationMissingException(error);
+      case 12:    return new DeprecatedException(error);
       case 17:    return new TooManyUserCallsException(error);
       case 21:    return new PageMigratedException(error);
       // 100..199: graph method errors
index 96f4bdd..dd02c20 100644 (file)
@@ -1,3 +1,3 @@
 org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
-de.juplo.facebook.errors.SpringSocialAutoConfiguration,\
-de.juplo.facebook.errors.OAuth2AutoConfiguration
+de.juplo.facebook.errors.FacebookErrorsSpringSocialAutoConfiguration,\
+de.juplo.facebook.errors.FacebookErrorsOAuth2AutoConfiguration
index 37ab056..65149d5 100644 (file)
@@ -88,6 +88,37 @@ public class GraphApiErrorHandlerTest
     }
   }
 
+  @Test
+  public void testError12()
+  {
+    log.info("testError12");
+
+
+    requestFactory.setBody(
+        "{\n" +
+        "  \"error\":\n" +
+        "  {\n" +
+        "    \"message\": \"(#12) location field is deprecated for versions v2.5 and higher\",\n" +
+        "    \"type\": \"OAuthException\",\n" +
+        "    \"code\": 12\n," +
+        "    \"fbtrace_id\":\"BoxCYne7GrL\"\n" +
+        "  }\n" +
+        "}");
+
+    try
+    {
+      clientTemplate.getForObject("ANY", SOME.class);
+      fail("The expected exception was not thrown");
+    }
+    catch(DeprecatedException e)
+    {
+      log.debug("{}", e.toString());
+      assertEquals(new Integer(12), e.getCode());
+      assertEquals("(#12) location field is deprecated for versions v2.5 and higher", e.getMessage());
+      assertEquals(Type.OAuthException, e.getType());
+    }
+  }
+
   @Test
   public void testError21()
   {