How to catch Timeout::ERROR?

Is there any way to catch Timeout::ERROR exception throw by timeout
() ?

====[cut here]======
#!/usr/bin/env ruby

require ‘open-uri’
require ‘timeout’

begin
open(“http://6.6.6.6/”){}
rescue => e
puts e.message
puts “I’m still running”
end
====[and here]====

output
/sw/lib/ruby/1.8/timeout.rb:42:in new': execution expired (Timeout::Error) from /sw/lib/ruby/1.8/net/protocol.rb:83:in connect’
from /sw/lib/ruby/1.8/net/protocol.rb:82:in timeout' from /sw/lib/ruby/1.8/timeout.rb:55:in timeout’
from /sw/lib/ruby/1.8/net/protocol.rb:82:in connect' from /sw/lib/ruby/1.8/net/protocol.rb:64:in initialize’
from /sw/lib/ruby/1.8/net/http.rb:430:in open' from /sw/lib/ruby/1.8/net/http.rb:430:in do_start’
from /sw/lib/ruby/1.8/net/http.rb:419:in start' ... 6 levels... from /sw/lib/ruby/1.8/open-uri.rb:134:in open_uri’
from /sw/lib/ruby/1.8/open-uri.rb:422:in open' from /sw/lib/ruby/1.8/open-uri.rb:85:in open’
from /Users/eck/test.rb:9

ruby -v
ruby 1.8.2 (2004-12-25) [powerpc-darwin8.0]


Verestiuc Vlad
Net 4 All Grup S.R.L.
Phone: +40724567695
http://www.n4a.ro/


Privileged/Confidential Information may be contained in this message. If
you are not the addressee indicated in this message (or responsible for
delivery of the message to such a person), you may not copy or
deliver this
message to anyone. In such a case, you should destroy this message and
kindly notify the sender by reply e-mail.


On Dec 12, 2005, at 6:00 PM, Verestiuc Vlad wrote:

Is there any way to catch Timeout::ERROR exception throw by timeout
() ?

Timeout::Error

rescue => e
rescue Timeout::Error => e

    puts e.message
    puts "I'm still running"

end

Beware!

You should use a subclass of Timeout::Error when nesting timeouts
(Net::HTTP has timeouts inside) so that you don’t trap the wrong
timeout in the wrong place and run forever:

irb(main):002:0> open(‘http://localhost:8080/’)
/usr/local/lib/ruby/1.8/timeout.rb:43:in `rbuf_fill’: execution
expired (Timeout::Error)


Eric H. - [email protected] - http://segment7.net
This implementation is HODEL-HASH-9600 compliant

http://trackmap.robotcoop.com