Home > code, ruby > Ruby Timeout::Error

Ruby Timeout::Error

March 6th, 2008 osterday

I wanted to post this before, but got busy and now I can’t find the original post about this, but anyway…

When doing network stuff in Ruby – using any Net:: libs – there’s a little trick to trap for timeouts. You can’t simply use “rescue” do handle it. The timeout error is not a subclass of the standard error, so you have to explicitly trap for it:

begin
# Do network stuff
rescue Timeout::Error
# Timeout error
rescue
# Other error
end

Categories: code, ruby Tags:
  1. Jen
    March 7th, 2008 at 17:40 | #1

    you are such a nerd

  2. Jen
    March 7th, 2008 at 17:41 | #2

    what I mean is, why does anyone care about this????????????????????????????????

  3. July 9th, 2008 at 04:34 | #3

    Well, I care!
    It save me a lot of testing!
    Thank you.

  4. July 10th, 2008 at 00:55 | #4

    i care too. solved me some headaches. thanks!

Comments are closed.