From: burke Date: 2010-02-14T13:55:06+09:00 Subject: Re: Q: will this always work: rescuing with non-Exception classes Interesting idea. Seems to work pretty much everywhere. ~ ✖ ruby-1.9.1-p378 ▸ rvm ruby test.rb macruby-nightly: MacRuby version 0.6 (ruby 1.9.0) [universal- darwin10.0, x86_64] Rescued! mput-head: ruby 1.9.2dev (2010-02-14 trunk 26661) [x86_64- darwin10.2.0] Rescued! rbx-1.0.0-rc2: rubinius 1.0.0-rc2 (1.8.7 release 2010-01-04 JI) [x86_64-apple-darwin10.2.0] Rescued! ree-1.8.7-2009.10: ruby 1.8.7 (2009-06-12 patchlevel 174) [i686- darwin10.2.0], MBARI 0x6770, Ruby Enterprise Edition 2009.10 Rescued! ruby-1.8.7-p248: ruby 1.8.7 (2009-12-24 patchlevel 248) [i686- darwin10.2.0] Rescued! ruby-1.9.1-p378: ruby 1.9.1p378 (2010-01-10 revision 26273) [i386- darwin10.2.0] Rescued! ~ ✖ ruby-1.9.1-p378 ▸ On Feb 13, 5:40 pm, Jeremy Henty wrote: > I wondered  whether the  clause rescue would  accept any  modules, not > just exception classes.  Well, at least in MRI 1.8.7, it does (example > appended).  But will this work in all Ruby implementations? > > Regards, > > Jeremy Henty > > Example (prints "Rescued!") > >     module MyModule >     end > >     class MyException < StandardError >       include MyModule >     end > >     begin >       raise MyException >     rescue MyModule >       puts 'Rescued!' >     end