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