我需要Timeout::Error
从 Redis 库中拯救一个 raise,但我遇到了一个问题,拯救那个特定的类似乎不起作用。
begin
Redis.new( { :host => "127.0.0.X" } )
rescue Timeout::Error => ex
end
=> Timeout::Error: Timeout::Error from /Users/me/.rvm/gems/ree-1.8.7-2011.03@gowalla/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/ree-1.8.7-2011.03@gowalla/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
任何线索如何挽救这个异常?