Added JSON-mapping for responses from the Graph-API
[facebook-errors] / src / main / java / de / juplo / facebook / exceptions / GraphApiException.java
index 03aa627..1055b20 100644 (file)
@@ -1,5 +1,8 @@
 package de.juplo.facebook.exceptions;
 
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.annotation.JsonPropertyOrder;
+import com.fasterxml.jackson.annotation.JsonRootName;
 import org.springframework.security.oauth2.common.exceptions.OAuth2Exception;
 
 /**
@@ -59,4 +62,30 @@ public class GraphApiException extends OAuth2Exception
     builder.append("}}");
     return builder.toString();
   }
+
+
+  /**
+   * This class represents an error message from the Graph-API
+   *
+   * @see https://developers.facebook.com/docs/graph-api/using-graph-api/v2.5#errors
+   */
+  @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;
+  }
 }