From: Sean O'Halpin Date: 2006-08-01T09:59:07+09:00 Subject: Re: Custom Exception classes On 7/31/06, Eric Hodel wrote: > On Jul 31, 2006, at 12:25 AM, Sean O'Halpin wrote: > > > On 7/29/06, Eric Hodel wrote: > >> On Jul 28, 2006, at 3:17 PM, Caleb Clausen wrote: > >> > >> > The following works for me. If you have code that doesn't work, > >> then > >> > please post it. > >> > > >> > class Hell >> > >> Please don't subclass Exception as a plain rescue won't catch these. > >> Use a more-descriptive subclass like RuntimeError or even > >> StandardError. > > > > I'm sure that used to be the case but it must have changed around 1.8 > > (not sure exactly when): > > > > begin > > raise Exception, "oops!" > > rescue > > p $! > > end > > #=> oops! (Exception) > > > > ruby 1.8.4 (2005-12-24) [i386-mswin32] > > Are you sure? > > $ ruby -ve 'begin; raise Exception; rescue; p "caught"; end' > ruby 1.8.5 (2006-07-25) [powerpc-darwin8.7.0] > -e:1: Exception (Exception) > $ > > -- > Eric Hodel - drbrain@segment7.net - http://blog.segment7.net > This implementation is HODEL-HASH-9600 compliant > > http://trackmap.robotcoop.com > No - you're right. I keep getting this mixed up :/ You have to do this to catch an Exception: begin raise Exception, "oops!" rescue Exception puts "caught" end #> caught I deleted Exception from the rescue clause, re-ran it and didn't read the output correctly. Apologies for the noise (of chomping humble pie ;) Regards, Sean