How to catch Koala::Facebook::APIError OAuthException or user password reset
i was wondering how i can catch a koala oauth exception (for example user password reset).
right now this is what i have / use so far:
rescue_from Koala::Facebook::APIError do
# redirect to fb auth dialog
end
but this catches all errors.. how i can do that with just oauth or only password reset?
EDIT:
found out a more e开发者_运维技巧xplicit solution to the problem:
rescue_from Koala::Facebook::APIError do |exception|
if exception.fb_error_type == 190
# password reset - redirect to auth dialog
else
raise "Facebook Error: #{exception.fb_error_type}"
end
end
thanks in advance oliver
I will show you some code I have, and how I manage to catch and rescue from Koala exceptions:
def post_message_facebook_wall(message)
unless self.token.nil?
begin
facebook_graph = Koala::Facebook::GraphAPI.new(self.token)
object_from_koala = facebook_graph.put_wall_post(message)
rescue Koala::Facebook::APIError => exc
logger.error("Problems posting to Facebook Wall..."+self.inspect+" "+exc.message)
end
end
end
This rescue Koala::Facebook::APIError => exc
should do the trick.
精彩评论