By developing some error handling code inside my Unity application in order to take custom actions when a request to Facebook fails (as forcing a local user logout or requesting a new permission) I saw some inconsistencies between the Facebook Graph API (Handling error codes) documentation and the results I am receiving for failed requests.
When trying to post a score (Scores API) without granting write permissions to my application, the request assigned callback receives a FBResult
containing:
result.Error == "403 Forbidden"
instead of something related to:
result.Error == {
"error": {
"message": "API Permission Denied",
"type": "",
"code": 10 ,
"error_subcode": 467
}
}
When looking to the FB sample friendsmash-unity they only ignore errors as presented in the next code snippet:
void APICallback(FBResult result)
{
Util.Log("APICallback");
if (result.Error != null)
{
Util.LogError(result.Error);
// Let's just try again
FB.API("/me?fields=id,first_name,friends.limit(100).fields(first_name,id)", Facebook.HttpMethod.GET, APICallback);
return;
}
Is Facebook using different patterns between the Graph API and the Scores API for handling errors?
Do I need to implement both JSON error and HTTP error parsers?
What are the best practices for handling Facebook errors inside a Unity application?