How to rescue all exceptions under a certain namespace?

Viewed 10585

Is there a way to rescue all exceptions under a certain namespace?

For example, I want to rescue all of the Errno::* exceptions (Errno::ECONNRESET, Errno::ETIMEDOUT). I can go ahead and list them all out on my exception line, but I was wondering if I can do something like.

begin
  # my code
rescue Errno
  # handle exception
end

The above idea doesn't seem to work, thus is there something similar that can work?

4 Answers
Related