From: Kai Moritz Date: Tue, 7 Jun 2016 13:03:31 +0000 (+0200) Subject: Refactoring: moved FacebookErrorMessage in its own file/class X-Git-Tag: wip-webclient~80 X-Git-Url: http://juplo.de/gitweb/?a=commitdiff_plain;h=24361a39e7ec511fd621c0fee59263e70ab0c2c9;p=facebook-errors Refactoring: moved FacebookErrorMessage in its own file/class --- diff --git a/src/main/java/de/juplo/facebook/exceptions/AccessTokenRequiredException.java b/src/main/java/de/juplo/facebook/exceptions/AccessTokenRequiredException.java index 2ac5e2f..c55fc36 100644 --- a/src/main/java/de/juplo/facebook/exceptions/AccessTokenRequiredException.java +++ b/src/main/java/de/juplo/facebook/exceptions/AccessTokenRequiredException.java @@ -1,9 +1,6 @@ package de.juplo.facebook.exceptions; -import de.juplo.facebook.exceptions.GraphApiException.FacebookErrorMessage; - - /** * 104: An access token is required to request this resource. diff --git a/src/main/java/de/juplo/facebook/exceptions/FacebookErrorMessage.java b/src/main/java/de/juplo/facebook/exceptions/FacebookErrorMessage.java new file mode 100644 index 0000000..a1bd4b3 --- /dev/null +++ b/src/main/java/de/juplo/facebook/exceptions/FacebookErrorMessage.java @@ -0,0 +1,42 @@ +package de.juplo.facebook.exceptions; + + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.annotation.JsonRootName; + + + +/** + * This class represents an error message from the Graph-API + * + * @see Graph-API Documentation + * @author Kai Moritz + */ +@JsonRootName("error") +@JsonPropertyOrder({ + "message", + "type", + "code", + "error_subcode", + "error_user_title", + "error_user_msg", + "fbtrace_id" + }) +public class FacebookErrorMessage +{ + @JsonProperty("message") + String message; + @JsonProperty("type") + String type; + @JsonProperty("code") + Integer code; + @JsonProperty("error_subcode") + Integer subCode; + @JsonProperty("error_user_title") + String userTitle; + @JsonProperty("error_user_msg") + String userMessage; + @JsonProperty("fbtrace_id") + String traceId; +} diff --git a/src/main/java/de/juplo/facebook/exceptions/GraphApiException.java b/src/main/java/de/juplo/facebook/exceptions/GraphApiException.java index 9379abe..375c5b8 100644 --- a/src/main/java/de/juplo/facebook/exceptions/GraphApiException.java +++ b/src/main/java/de/juplo/facebook/exceptions/GraphApiException.java @@ -1,8 +1,5 @@ package de.juplo.facebook.exceptions; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonPropertyOrder; -import com.fasterxml.jackson.annotation.JsonRootName; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.DeserializationFeature; @@ -144,30 +141,4 @@ public class GraphApiException extends OAuth2Exception return e.getMessage(); } } - - - /** - * This class represents an error message from the Graph-API - * - * @see Graph-API Documentation - */ - @JsonRootName("error") - @JsonPropertyOrder({ "message", "type", "code", "error_subcode", "error_user_title", "error_user_msg", "fbtrace_id" }) - public static class FacebookErrorMessage - { - @JsonProperty("message") - String message; - @JsonProperty("type") - String type; - @JsonProperty("code") - Integer code; - @JsonProperty("error_subcode") - Integer subCode; - @JsonProperty("error_user_title") - String userTitle; - @JsonProperty("error_user_msg") - String userMessage; - @JsonProperty("fbtrace_id") - String traceId; - } } diff --git a/src/main/java/de/juplo/facebook/exceptions/OAuthException.java b/src/main/java/de/juplo/facebook/exceptions/OAuthException.java index e8fd312..2235dde 100644 --- a/src/main/java/de/juplo/facebook/exceptions/OAuthException.java +++ b/src/main/java/de/juplo/facebook/exceptions/OAuthException.java @@ -1,9 +1,6 @@ package de.juplo.facebook.exceptions; -import de.juplo.facebook.exceptions.GraphApiException.FacebookErrorMessage; - - /** * Baseclass for exceptions of type {@code OAuthException}. diff --git a/src/main/java/de/juplo/facebook/exceptions/UnexpectedErrorException.java b/src/main/java/de/juplo/facebook/exceptions/UnexpectedErrorException.java index 6d7369b..c639c26 100644 --- a/src/main/java/de/juplo/facebook/exceptions/UnexpectedErrorException.java +++ b/src/main/java/de/juplo/facebook/exceptions/UnexpectedErrorException.java @@ -1,9 +1,6 @@ package de.juplo.facebook.exceptions; -import de.juplo.facebook.exceptions.GraphApiException.FacebookErrorMessage; - - /** * 2: An unexpected error has occurred. diff --git a/src/main/java/de/juplo/facebook/exceptions/UnknownErrorException.java b/src/main/java/de/juplo/facebook/exceptions/UnknownErrorException.java index c281f09..b38341a 100644 --- a/src/main/java/de/juplo/facebook/exceptions/UnknownErrorException.java +++ b/src/main/java/de/juplo/facebook/exceptions/UnknownErrorException.java @@ -1,9 +1,6 @@ package de.juplo.facebook.exceptions; -import de.juplo.facebook.exceptions.GraphApiException.FacebookErrorMessage; - - /** * 1: An unknown error has occurred. diff --git a/src/test/java/de/juplo/facebook/exceptions/FacebookErrorMessageMappingTest.java b/src/test/java/de/juplo/facebook/exceptions/FacebookErrorMessageMappingTest.java index 3d672a4..ed1cba8 100644 --- a/src/test/java/de/juplo/facebook/exceptions/FacebookErrorMessageMappingTest.java +++ b/src/test/java/de/juplo/facebook/exceptions/FacebookErrorMessageMappingTest.java @@ -1,13 +1,15 @@ package de.juplo.facebook.exceptions; + import com.fasterxml.jackson.core.JsonProcessingException; -import de.juplo.facebook.exceptions.GraphApiException.FacebookErrorMessage; import static de.juplo.facebook.exceptions.GraphApiException.OBJECT_MAPPER; import de.juplo.facebook.exceptions.GraphApiException.Type; import java.io.IOException; import org.junit.Test; import static org.junit.Assert.assertEquals; + + /** * @author Kai Moritz */