Hi,

At Fri, 16 Mar 2007 08:09:06 +0900,
Brian Candler wrote in [ruby-core:10617]:
> > > I was just caught out by this odd behaviour: a 'rescue' clause doesn't
> > > generate an error if given a non-exception class. I had actually written
> > >   rescue Timeout
> > > which was silently accepted but didn't work. Actually it should have been
> > >   rescue TimeoutError
> > 
> > Modules also are allowed there.
> 
> ... and a class is_a module. Obviously, a class which is a subclass of
> Exception is useful here. But is it ever useful to match against a class
> which is not a subclass of Exception?

No, what is allowed there is a subclass of Exception, or an
instance of Module but not Class.

For instance, ext/iconv defines some exceptions,
InvalidEncoding, IllegalSequence and InvalidCharacter those are
subclasses of ArgumentError, and OutOfRange and BrokenLibrary
those are subclasses of RuntimeError.  But you can catch them
at once by rescuing Iconv::Failure.

-- 
Nobu Nakada