Catching Timeout::Error from Net::HTTP::new.start()

I've decided to add reCAPTCHA 'prove you're not a bot' to my signup page, and plan on sprinkling it around in various places when people want to post to forums, etc. I know I could use the thing that is already written... but since a simple 'gem install recaptcha' does not work, but instead needs a --source flag, I won't use it.

I also want to know what my code is doing, so I am writing my own. :slight_smile:

In the verify method, I have:

It turns out I found the 'answer' I wrapped my http fetch with:

    begin       response = http.start do |http|         http.request(req)       end     rescue Timeout::Error => e       return nil # XXXMLG this is ok for now...     end

This traps the Timeout::Error

Now, are there two classes of exceptions in Ruby? An exception that is trapped using the normal

begin   ... rescue   ... end

block and one that is not unless you specifically name it?

--Michael

begin ... rescue ... end doesn't actually mean rescue everything. It means rescue everything that derives from StandardError, which apparently Timeout::Error doesn't. To rescue truely everything, you need rescue Exception. (see http://faq.rubygarden.org/entry/show/105?controller_prefix=faq%2F)

Fred