本文整理汇总了Java中com.restfb.exception.FacebookException.getMessage方法的典型用法代码示例。如果您正苦于以下问题:Java FacebookException.getMessage方法的具体用法?Java FacebookException.getMessage怎么用?Java FacebookException.getMessage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.restfb.exception.FacebookException
的用法示例。
在下文中一共展示了FacebookException.getMessage方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: isFriendWithCurrentUser
import com.restfb.exception.FacebookException; //导入方法依赖的package包/类
@Override
public boolean isFriendWithCurrentUser(String externalUserId,
User currentUser) {
if (!isServiceEnabled(currentUser)) {
return false;
}
FacebookClient client = helper.getFacebookClient(currentUser);
try {
com.restfb.types.User friend = client.fetchObject(
currentUser.getFacebookSettings().getUserId() + "/friends/"
+ getFacebookId(externalUserId),
com.restfb.types.User.class);
return friend != null;
} catch (FacebookException ex) {
if (ex.getMessage() != null && ex.getMessage().contains("#110")) {
//TODO this is a page, handle pages as well
return true;
} else {
handleException("Problem getting friends of user " + externalUserId, ex, currentUser);
}
}
return false;
}
示例2: handleException
import com.restfb.exception.FacebookException; //导入方法依赖的package包/类
private void handleException(String message, FacebookException ex, User user) {
SocialNetworkStatusHolder.addStatus("facebookProblem");
// well, technically, this is not a best practice,
// but thus a lot of code duplication is avoided.
// Also, checking for a string in the exception message
// is not good, but that seems the only way to determine the exact exception
if (ex instanceof FacebookNetworkException) {
logger.warn(message + ": " + ex.getMessage() + " : " + ExceptionUtils.getRootCauseMessage(ex));
} else if (ex instanceof FacebookGraphException) {
if (ex.getMessage() != null) {
String errorMessage = ex.getMessage().toLowerCase();
// if the token is not valid, or the user has revoked a
// permission (arbitrarily chosen manage_notifications),
// disconnect
if (errorMessage.contains("validating access token") || errorMessage.contains("manage_notifications")) {
// resetting facebook token
SocialNetworkStatusHolder.addStatus("facebookTokenProblem");
logger.info("Access token problem with user " + user + ". Resetting token. The problem is due to exception: " + ex.getMessage());
user.getFacebookSettings().setDisconnectReason(errorMessage);
helper.forciblyDisconnect(this, user);
return;
}
if (errorMessage.contains("#803") // object missing
|| errorMessage.contains("#200") // object not accessible
|| errorMessage.contains("#210") // user not accessible
|| errorMessage.contains("#100") // invalid parameter - given when delete is attempted on non-existent status
|| errorMessage.contains("#506") // duplicate status
|| errorMessage.contains("Unsupported delete request")) { // missing target object for deletion
// ignore, do nothing, log in debug only
logger.debug(message + ": " + ex.getMessage() + " : " + ExceptionUtils.getRootCauseMessage(ex), " | User is " + user);
return;
}
if (errorMessage.contains("#341")) {
logger.info("Facebook post limit reached by user: " + user);
return;
}
}
logger.warn(message + " | User is " + user, ex);
} else {
logger.warn(message + " | User is " + user, ex);
}
}