1 package de.juplo.facebook;
3 import org.springframework.security.oauth2.common.exceptions.OAuth2Exception;
6 * Base exception for Facebook Graph-Api exceptions.
10 @org.codehaus.jackson.map.annotate.JsonSerialize(using = GraphApiExceptionJackson1Serializer.class)
11 @org.codehaus.jackson.map.annotate.JsonDeserialize(using = GraphApiExceptionJackson1Deserializer.class)
12 @com.fasterxml.jackson.databind.annotation.JsonSerialize(using = GraphApiExceptionJackson2Serializer.class)
13 @com.fasterxml.jackson.databind.annotation.JsonDeserialize(using = GraphApiExceptionJackson2Deserializer.class)
14 public class GraphApiException extends OAuth2Exception
16 private final String type;
17 private final int code;
19 private int httpErrorCode;
22 public GraphApiException(String message, String type, int code)
30 public String getType()
41 public int getHttpErrorCode()
43 return httpErrorCode == 0 ? super.getHttpErrorCode() : httpErrorCode;
46 public void setHttpErrorCode(int httpErrorCode)
48 this.httpErrorCode = httpErrorCode;
52 public String toString()
54 StringBuilder builder = new StringBuilder();
55 builder.append("{error:{\"message\":\"");
56 builder.append(getMessage().replaceAll("\"", "\\\""));
57 builder.append("\",\"type\":");
58 builder.append(type.replaceAll("\"", "\\\""));
59 builder.append("\",\"code\":");
62 return builder.toString();