How to catch Timeout::ERROR ?

V

Verestiuc Vlad

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,962
Messages
2,570,134
Members
46,690
Latest member
MacGyver

Latest Threads

Top