假设消息参数是一个字符串,我有以下代码段:
users.each do |user|
posted = Facebook.post_to_facebook(message,user.token)
end然后,post_to_facebook是这样一种方法:
def post_to_facebook
facebook_graph = Koala::Facebook::GraphAPI.new(token)
object_from_koala = facebook_graph.put_wall_post(message)
end对于一些用户来说,在调用put_wall_post时,我得到了一个例外:Koala::Facebook::APIError。我只想跳过发送到那个用户的墙,然后转到下一个用户,但是我看不出如何管理异常。
发布于 2012-03-26 20:29:56
你可能需要这样的救援,也许你可以处理你的异常
def post_to_facebook
begin
facebook_graph = Koala::Facebook::GraphAPI.new(token)
object_from_koala = facebook_graph.put_wall_post(message)
rescue
do something else
endhttps://stackoverflow.com/questions/9879284
复制相似问题