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

1

7

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 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

Backchat answered 1/9, 2011 at 13:24 Comment(0)
I
2

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.

Iceblink answered 27/3, 2012 at 18:20 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.