使用Google Ruby Client处理oauth错误?

Handle oauth errors with Google Ruby Client?

我正在Rails Web应用程序中使用Google API Ruby客户端(gem'google-api-client'),我想知道如何在oauth流程中捕获特定错误。特别是在救援声明中我应该寻找什么?这是用户授权后重定向所调用的函数:

1
2
3
4
5
6
7
8
9
10
11
12
13
require 'google/api_client'

def google_auth_finish
  begin
    client = Google::APIClient.new
    client.authorization.client_id = GOOGLE_CLIENT_ID
    client.authorization.client_secret = GOOGLE_CLIENT_SECRET
    ...
  rescue ## WHAT GOES HERE TO IDENTIFY THE ERROR?
    # Handle the error
    logger.info"There was an error."
  end
end

在某处存在定义错误的参考?我已经搜索了,找不到了。


我知道这是几年前被问到的,但是我确实遇到了这个问题,并且偶然地遇到了这个问题。您只缺少一小部分。这对我有用。我还是一个相对较新的人,但就我而言,它阻止了程序的崩溃并打印出错误消息,然后程序继续运行。

1
2
3
rescue Exception => error
      puts"Error #{error}"
end

尝试这些引发异常