Package com.restfb.exception.generator
Interface FacebookExceptionGenerator
-
- All Known Implementing Classes:
DefaultFacebookExceptionGenerator
public interface FacebookExceptionGenerator
Generator to convert Facebook error JSON into RestFB Exceptions.Provides methods to convert graph api errors and batch errors.
-
-
Field Summary
Fields Modifier and Type Field Description static String
BATCH_ERROR_ATTRIBUTE_NAME
Batch API error response 'error' attribute name.static String
BATCH_ERROR_DESCRIPTION_ATTRIBUTE_NAME
Batch API error response 'error_description' attribute name.static String
ERROR_ATTRIBUTE_NAME
API error response 'error' attribute name.static String
ERROR_CODE_ATTRIBUTE_NAME
API error response 'code' attribute name.static String
ERROR_IS_TRANSIENT_NAME
static String
ERROR_MESSAGE_ATTRIBUTE_NAME
API error response 'message' attribute name.static String
ERROR_SUBCODE_ATTRIBUTE_NAME
API error response 'error_subcode' attribute name.static String
ERROR_TYPE_ATTRIBUTE_NAME
API error response 'type' attribute name.static String
ERROR_USER_MSG_ATTRIBUTE_NAME
API error response 'error_user_msg' attribute name.static String
ERROR_USER_TITLE_ATTRIBUTE_NAME
API error response 'error_user_title' attribute name.
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description void
throwBatchFacebookResponseStatusExceptionIfNecessary(String json, Integer httpStatusCode)
If theerror
anderror_description
JSON fields are present, we've got a response status error for this batch API call.void
throwFacebookResponseStatusExceptionIfNecessary(String json, Integer httpStatusCode)
Throws an exception if Facebook returned an error response.
-
-
-
Field Detail
-
ERROR_ATTRIBUTE_NAME
static final String ERROR_ATTRIBUTE_NAME
API error response 'error' attribute name.- See Also:
- Constant Field Values
-
ERROR_TYPE_ATTRIBUTE_NAME
static final String ERROR_TYPE_ATTRIBUTE_NAME
API error response 'type' attribute name.- See Also:
- Constant Field Values
-
ERROR_USER_TITLE_ATTRIBUTE_NAME
static final String ERROR_USER_TITLE_ATTRIBUTE_NAME
API error response 'error_user_title' attribute name.- See Also:
- Constant Field Values
-
ERROR_USER_MSG_ATTRIBUTE_NAME
static final String ERROR_USER_MSG_ATTRIBUTE_NAME
API error response 'error_user_msg' attribute name.- See Also:
- Constant Field Values
-
ERROR_MESSAGE_ATTRIBUTE_NAME
static final String ERROR_MESSAGE_ATTRIBUTE_NAME
API error response 'message' attribute name.- See Also:
- Constant Field Values
-
ERROR_CODE_ATTRIBUTE_NAME
static final String ERROR_CODE_ATTRIBUTE_NAME
API error response 'code' attribute name.- See Also:
- Constant Field Values
-
ERROR_IS_TRANSIENT_NAME
static final String ERROR_IS_TRANSIENT_NAME
- See Also:
- Constant Field Values
-
ERROR_SUBCODE_ATTRIBUTE_NAME
static final String ERROR_SUBCODE_ATTRIBUTE_NAME
API error response 'error_subcode' attribute name.- See Also:
- Constant Field Values
-
BATCH_ERROR_ATTRIBUTE_NAME
static final String BATCH_ERROR_ATTRIBUTE_NAME
Batch API error response 'error' attribute name.- See Also:
- Constant Field Values
-
BATCH_ERROR_DESCRIPTION_ATTRIBUTE_NAME
static final String BATCH_ERROR_DESCRIPTION_ATTRIBUTE_NAME
Batch API error response 'error_description' attribute name.- See Also:
- Constant Field Values
-
-
Method Detail
-
throwFacebookResponseStatusExceptionIfNecessary
void throwFacebookResponseStatusExceptionIfNecessary(String json, Integer httpStatusCode)
Throws an exception if Facebook returned an error response. Using the Graph API, it's possible to see both the new Graph API-style errors as well as Legacy API-style errors, so we have to handle both here. This method extracts relevant information from the error JSON and throws an exception which encapsulates it for end-user consumption.For Graph API errors:
If the
error
JSON field is present, we've got a response status error for this API call.For Legacy errors (e.g. FQL):
If the
error_code
JSON field is present, we've got a response status error for this API call.- Parameters:
json
- The JSON returned by Facebook in response to an API call.httpStatusCode
- The HTTP status code returned by the server, e.g. 500.- Throws:
FacebookGraphException
- If the JSON contains a Graph API error response.FacebookResponseStatusException
- If the JSON contains an Legacy API error response.FacebookJsonMappingException
- If an error occurs while processing the JSON.
-
throwBatchFacebookResponseStatusExceptionIfNecessary
void throwBatchFacebookResponseStatusExceptionIfNecessary(String json, Integer httpStatusCode)
If theerror
anderror_description
JSON fields are present, we've got a response status error for this batch API call. Extracts relevant information from the JSON and throws an exception which encapsulates it for end-user consumption.- Parameters:
json
- The JSON returned by Facebook in response to a batch API call.httpStatusCode
- The HTTP status code returned by the server, e.g. 500.- Throws:
FacebookResponseStatusException
- If the JSON contains an error code.FacebookJsonMappingException
- If an error occurs while processing the JSON.- Since:
- 1.6.5
-
-