How to catch Koala :: Facebook :: APIError OAuthException or user password reset

I was wondering how I can catch the koala oauth exception (e.g. user password reset).

right now this is what i / use so far:

rescue_from Koala::Facebook::APIError do # redirect to fb auth dialog end 

but it catches all the errors .. how can I do this with just oauth or just reset password?

EDIT:

found a more explicit 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

+7
source share
1 answer

I will show you the code that I have, and how I manage to catch and save Koalas from 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.

+2
source

All Articles