From: Kai Moritz Date: Fri, 15 Jan 2016 14:39:37 +0000 (+0100) Subject: WIP: Wo war ich da stehen geblieben...? X-Git-Url: http://juplo.de/gitweb/?a=commitdiff_plain;h=5db7dd6aafb490a8a7cbdf3e1adf3066e11f96f5;p=facebook-utils WIP: Wo war ich da stehen geblieben...? http://stackoverflow.com/questions/10478812/facebook-graph-api-error-code-list http://fbdevwiki.com/wiki/Error_codes https://developers.facebook.com/docs/payments/reference/errorcodes --- diff --git a/src/main/java/de/juplo/facebook/exceptions/GraphApiException.java b/src/main/java/de/juplo/facebook/exceptions/GraphApiException.java index 9379abe..0a2559f 100644 --- a/src/main/java/de/juplo/facebook/exceptions/GraphApiException.java +++ b/src/main/java/de/juplo/facebook/exceptions/GraphApiException.java @@ -69,6 +69,7 @@ public class GraphApiException extends OAuth2Exception case 21: return new PageMigratedException(error); // 100..199: graph method errors case 100: return new UnsupportedGetRequestException(error); + case 102: return new UserAccessTokenRequiredException(error); case 104: return new AccessTokenRequiredException(error); // 200..299: permission errors // 300..399: data editing errors diff --git a/src/main/java/de/juplo/facebook/exceptions/UserAccessTokenRequiredException.java b/src/main/java/de/juplo/facebook/exceptions/UserAccessTokenRequiredException.java new file mode 100644 index 0000000..16b8bc2 --- /dev/null +++ b/src/main/java/de/juplo/facebook/exceptions/UserAccessTokenRequiredException.java @@ -0,0 +1,14 @@ +package de.juplo.facebook.exceptions; + + +/** + * A user access token is required to request this resource. + * @author Kai Moritz + */ +public class UserAccessTokenRequiredException extends OAuthException +{ + public UserAccessTokenRequiredException(FacebookErrorMessage error) + { + super(error); + } +} diff --git a/src/test/java/de/juplo/facebook/client/GraphApiErrorHandlerTest.java b/src/test/java/de/juplo/facebook/client/GraphApiErrorHandlerTest.java index c9921fa..0c900b3 100644 --- a/src/test/java/de/juplo/facebook/client/GraphApiErrorHandlerTest.java +++ b/src/test/java/de/juplo/facebook/client/GraphApiErrorHandlerTest.java @@ -10,6 +10,7 @@ import de.juplo.facebook.exceptions.GraphApiException.Type; import de.juplo.facebook.exceptions.UnknownErrorException; import de.juplo.facebook.exceptions.PageMigratedException; import de.juplo.facebook.exceptions.UnmappedErrorException; +import de.juplo.facebook.exceptions.UserAccessTokenRequiredException; import java.util.Date; import java.util.Map; import java.util.Set; @@ -182,6 +183,29 @@ public class GraphApiErrorHandlerTest } } + @Test + public void testError102() + { + log.info("testError102"); + + requestFactory.setBody("{\"error\":{\"message\":\"A user access token is required to request this resource.\",\"type\":\"OAuthException\",\"code\":102,\"fbtrace_id\":\"DhdMyf23Ki7\"}}"); + + try + { + clientTemplate.getForObject("ANY", SOME.class); + fail("The expected exception was not thrown"); + } + catch(UserAccessTokenRequiredException e) + { + log.debug("{}", e.toString()); + assertEquals("invalid_request", e.getOAuth2ErrorCode()); + assertEquals(new Integer(102), e.getCode()); + assertEquals("A user access token is required to request this resource.", e.getMessage()); + assertEquals(Type.OAuthException, e.getType()); + assertEquals("DhdMyf23Ki7", e.getTraceId()); + } + } + @Test public void testError104() {