M
Mark Probert
Hi ..
I have the following code:
def alive?(host,port)
ok = false
begin
Timeout::timeout(30) {
begin
t = TCPSocket.new(host,port)
t.close
ok = true
rescue Exception => e
@exception = e
end
}
rescue Timeout::Error => e
@exception = e
end
return ok
end
In a known failure case, TCPSocket will fail (no host connectivity).
This will cause timeout() to trigger an exception that will get caught by
the Timeout::Error handler. Right?
However,
13:56 (hobbes)$ ruby foo.rb
Exception `Errno::ETIMEDOUT' at ./bsn.rb:150 - Connection timed out -
13:57 (hobbes)$ ruby -v
ruby 1.8.1 (2003-12-25) [i386-cygwin]
What is the right way of handling this exception?
I have the following code:
def alive?(host,port)
ok = false
begin
Timeout::timeout(30) {
begin
t = TCPSocket.new(host,port)
t.close
ok = true
rescue Exception => e
@exception = e
end
}
rescue Timeout::Error => e
@exception = e
end
return ok
end
In a known failure case, TCPSocket will fail (no host connectivity).
This will cause timeout() to trigger an exception that will get caught by
the Timeout::Error handler. Right?
However,
13:56 (hobbes)$ ruby foo.rb
Exception `Errno::ETIMEDOUT' at ./bsn.rb:150 - Connection timed out -
13:57 (hobbes)$ ruby -v
ruby 1.8.1 (2003-12-25) [i386-cygwin]
What is the right way of handling this exception?