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
Modifier and TypeFieldDescriptionstatic final String
Batch API error response 'error' attribute name.static final String
Batch API error response 'error_description' attribute name.static final String
API error response 'error' attribute name.static final String
API error response 'code' attribute name.static final String
static final String
API error response 'message' attribute name.static final String
API error response 'error_subcode' attribute name.static final String
API error response 'type' attribute name.static final String
API error response 'error_user_msg' attribute name.static final String
API error response 'error_user_title' attribute name. -
Method Summary
Modifier and TypeMethodDescriptionvoid
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 Details
-
ERROR_ATTRIBUTE_NAME
API error response 'error' attribute name.- See Also:
-
ERROR_TYPE_ATTRIBUTE_NAME
API error response 'type' attribute name.- See Also:
-
ERROR_USER_TITLE_ATTRIBUTE_NAME
API error response 'error_user_title' attribute name.- See Also:
-
ERROR_USER_MSG_ATTRIBUTE_NAME
API error response 'error_user_msg' attribute name.- See Also:
-
ERROR_MESSAGE_ATTRIBUTE_NAME
API error response 'message' attribute name.- See Also:
-
ERROR_CODE_ATTRIBUTE_NAME
API error response 'code' attribute name.- See Also:
-
ERROR_IS_TRANSIENT_NAME
- See Also:
-
ERROR_SUBCODE_ATTRIBUTE_NAME
API error response 'error_subcode' attribute name.- See Also:
-
BATCH_ERROR_ATTRIBUTE_NAME
Batch API error response 'error' attribute name.- See Also:
-
BATCH_ERROR_DESCRIPTION_ATTRIBUTE_NAME
Batch API error response 'error_description' attribute name.- See Also:
-
-
Method Details
-
throwFacebookResponseStatusExceptionIfNecessary
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
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
-