1
我需要挽救從Redis庫中引發的Timeout::Error
,但是我遇到了一個問題,救出那個特定的類似乎不起作用。救援超時::錯誤來自Redis Gem(Ruby)
begin
Redis.new({ :host => "127.0.0.X" })
rescue Timeout::Error => ex
end
=> Timeout::Error: Timeout::Error from /Users/me/.rvm/gems/[email protected]/gems/redis-2.2.0/lib/redis/connection/hiredis.rb:23:in `connect'
當我設法營救Exception
它仍然無法正常工作
begin
Redis.new({ :host => "127.0.0.X" })
rescue Exception => ex
end
=> Timeout::Error: Timeout::Error from /Users/me/.rvm/gems/[email protected]/gems/redis-2.2.0/lib/redis/connection/hiredis.rb:23:in `connect'
如果我嘗試手動引發異常,我能救它,但不知道爲什麼我不能救當它從Redis Gem(2.2.0)中調用時。
begin
raise Timeout::Error
rescue Timeout::Error => ex
puts ex
end
Timeout::Error
=> nil
任何線索如何拯救此異常?
就我而言(參見上面的問題,如果我的編輯被批准),這個答案幫助我弄清楚IRB的「昆蟲」是問題的根源。 謝謝Devid! –