1 package de.juplo.facebook.exceptions;
3 import com.fasterxml.jackson.annotation.JsonProperty;
4 import com.fasterxml.jackson.annotation.JsonPropertyOrder;
5 import com.fasterxml.jackson.annotation.JsonRootName;
6 import org.springframework.security.oauth2.common.exceptions.OAuth2Exception;
9 * Base exception for Facebook Graph-Api exceptions.
13 @org.codehaus.jackson.map.annotate.JsonDeserialize(using = GraphApiExceptionJackson1Deserializer.class)
14 @com.fasterxml.jackson.databind.annotation.JsonDeserialize(using = GraphApiExceptionJackson2Deserializer.class)
15 public class GraphApiException extends OAuth2Exception
17 private final String type;
18 private final int code;
20 private int httpErrorCode;
23 public GraphApiException(String message, String type, int code)
31 public String getType()
42 public int getHttpErrorCode()
44 return httpErrorCode == 0 ? super.getHttpErrorCode() : httpErrorCode;
47 public void setHttpErrorCode(int httpErrorCode)
49 this.httpErrorCode = httpErrorCode;
53 public String toString()
55 StringBuilder builder = new StringBuilder();
56 builder.append("{error:{\"message\":\"");
57 builder.append(getMessage().replaceAll("\"", "\\\""));
58 builder.append("\",\"type\":");
59 builder.append(type.replaceAll("\"", "\\\""));
60 builder.append("\",\"code\":");
63 return builder.toString();
68 * This class represents an error message from the Graph-API
70 * @see https://developers.facebook.com/docs/graph-api/using-graph-api/v2.5#errors
72 @JsonRootName("error")
73 @JsonPropertyOrder({ "message", "type", "code", "error_subcode", "error_user_title", "error_user_msg", "fbtrace_id" })
74 public static class FacebookErrorMessage
76 @JsonProperty("message")
82 @JsonProperty("error_subcode")
84 @JsonProperty("error_user_title")
86 @JsonProperty("error_user_msg")
88 @JsonProperty("fbtrace_id")