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

4

1 回答 1

2

我将向您展示我拥有的一些代码,以及我如何设法从 Koala 异常中捕获和拯救:

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

rescue Koala::Facebook::APIError => exc应该可以解决问题。

于 2012-03-27T18:20:25.750 回答