是否可以在 ruby 中多次挽救相同的错误类型?我需要像这样使用 Koala facebook API 库:
begin
# Try with user provided app token
fb = Koala::Facebook::API.new(user_access_token)
fb.put_connections(user_id, {}) # TODO
rescue AuthenticationError
# User access token has expired or is fake
fb = Koala::Facebook::API.new(APP_FB_TOKEN)
fb.put_connections(user_id, {}) # TODO
rescue AuthenticationError
# User hasn't authed the app on facebook
puts "Could not authenticate"
next
rescue => e
puts "Error when posting to facebook"
puts e.message
next
end
如果没有办法两次挽救相同的错误,是否有更好的方法来推理这个问题?