我有一个发布到Facebook的Rails应用程序。我进行了一次救援以防止两次发布相同消息的错误。我想让我的应用程序只是通知用户并继续前进,但我似乎无法解决此错误。
这是我的代码:
begin
current_user.facebook.feed!(:message => 'THIS IS A TEST PLEASE IGNORE::Hello, Facebook!')
rescue FbGraph::Unauthorized
flash[:alert] = "Already Posted"
end
redirect_to show(@track)
我使用此代码获得的错误是:
OAuthException ::(#506)重复状态消息
答案 0 :(得分:1)
为什么在您收到FbGraph::Unauthorized
错误时从OAuthException
获救?
begin
current_user.facebook.feed!(:message => 'THIS IS A TEST PLEASE IGNORE::Hello, Facebook!')
rescue OAuthException
flash[:alert] = "Already Posted"
end
redirect_to show(@track)
答案 1 :(得分:0)
尝试:
begin
current_user.facebook.feed!(:message => 'THIS IS A TEST PLEASE IGNORE::Hello, Facebook!')
rescue => e
if(e.fb_error_type == "OAuthException"
flash[:alert] = "Already Posted"
end
end