+function handleFacebookError($e, $notice, $flink)
+{
+ $fbuid = $flink->foreign_id;
+ $user = $flink->getUser();
+ $code = $e->getCode();
+ $errmsg = $e->getMessage();
+
+ // XXX: Check for any others?
+ switch($code) {
+ case 100: // Invalid parameter
+ $msg = "FacebookPlugin - Facebook claims notice %d was posted with an invalid parameter (error code 100):"
+ . "\"%s\" (Notice details: nickname=%s, user ID=%d, Facebook ID=%d, notice content=\"%s\"). "
+ . "Removing notice from the Facebook queue for safety.";
+ common_log(
+ LOG_ERR, sprintf(
+ $msg,
+ $notice->id,
+ $errmsg,
+ $user->nickname,
+ $user->id,
+ $fbuid,
+ $notice->content
+ )
+ );
+ return true;
+ break;
+ case 200: // Permissions error
+ case 250: // Updating status requires the extended permission status_update
+ remove_facebook_app($flink);
+ return true; // dequeue
+ break;
+ case 341: // Feed action request limit reached
+ $msg = "FacebookPlugin - User %s (User ID=%d, Facebook ID=%d) has exceeded "
+ . "his/her limit for posting notices to Facebook today. Dequeuing "
+ . "notice %d.";
+ common_log(
+ LOG_INFO, sprintf(
+ $msg,
+ $user->nickname,
+ $user->id,
+ $fbuid,
+ $notice->id
+ )
+ );
+ // @fixme: We want to rety at a later time when the throttling has expired
+ // instead of just giving up.
+ return true;
+ break;
+ default:
+ $msg = "FacebookPlugin - Facebook returned an error we don't know how to deal with while trying to "
+ . "post notice %d. Error code: %d, error message: \"%s\". (Notice details: "
+ . "nickname=%s, user ID=%d, Facebook ID=%d, notice content=\"%s\"). Removing notice "
+ . "from the Facebook queue for safety.";
+ common_log(
+ LOG_ERR, sprintf(
+ $msg,
+ $notice->id,
+ $code,
+ $errmsg,
+ $user->nickname,
+ $user->id,
+ $fbuid,
+ $notice->content
+ )
+ );
+ return true; // dequeue
+ break;
+ }
+}