From: Kai Moritz Date: Tue, 23 Aug 2016 18:26:17 +0000 (+0200) Subject: Added an exception for error 12: X field is deprecated vor version vY.Z and higher X-Git-Tag: wip-webclient~64 X-Git-Url: http://juplo.de/gitweb/?a=commitdiff_plain;h=ed0c2ced1ecabf694f9f5de546bbcf01990a359a;p=facebook-errors Added an exception for error 12: X field is deprecated vor version vY.Z and higher --- diff --git a/pom.xml b/pom.xml index 1d81845..87331b4 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ org.springframework.boot spring-boot-starter-parent - 1.3.5.RELEASE + 1.3.7.RELEASE 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 index 0000000..8274cb6 --- /dev/null +++ b/src/main/java/de/juplo/facebook/errors/DeprecatedException.java @@ -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); + } +} diff --git a/src/main/java/de/juplo/facebook/errors/GraphApiException.java b/src/main/java/de/juplo/facebook/errors/GraphApiException.java index 9558b9d..53f075e 100644 --- a/src/main/java/de/juplo/facebook/errors/GraphApiException.java +++ b/src/main/java/de/juplo/facebook/errors/GraphApiException.java @@ -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 diff --git a/src/main/resources/META-INF/spring.factories b/src/main/resources/META-INF/spring.factories index 96f4bdd..dd02c20 100644 --- a/src/main/resources/META-INF/spring.factories +++ b/src/main/resources/META-INF/spring.factories @@ -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 diff --git a/src/test/java/de/juplo/facebook/errors/GraphApiErrorHandlerTest.java b/src/test/java/de/juplo/facebook/errors/GraphApiErrorHandlerTest.java index 37ab056..65149d5 100644 --- a/src/test/java/de/juplo/facebook/errors/GraphApiErrorHandlerTest.java +++ b/src/test/java/de/juplo/facebook/errors/GraphApiErrorHandlerTest.java @@ -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() {