0

我有一个发布到 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) 重复状态消息

4

2 回答 2

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)
于 2011-12-12T18:21:35.500 回答
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
于 2012-03-06T17:39:18.140 回答