[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

How to catch Timeout::ERROR ?

Verestiuc Vlad

12/13/2005 2:00:00 AM



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....){}
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://w...
------------------------------------------------------------------------
---
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.
------------------------------------------------------------------------
---