From: Daniel Berger Date: 2005-05-14T10:30:29+09:00 Subject: Re: Customing the Exception class Eric Hodel wrote: > On 13 May 2005, at 14:35, Ara.T.Howard@noaa.gov wrote: > > > On Sat, 14 May 2005, Daniel Berger wrote: > > > > > >> Hi all, > >> > >> I have a program where I want to send all errors to a file. So, I > >> did this: > > [snip] > > >> This works for most errors, but it doesn't seem to work when the > >> error > >> is a SystemCallError. > >> > >> For example, this writes to the log as expected: > >> > >> print "Some crazy division: " > >> p 1/0 > >> > >> But this does not: > >> > >> File.open("non-existant file") > >> > >> The latter raises an Errno::ENOENT. > >> > >> Why, if SystemCallError is a subclass of Exception, does my > >> approach not > >> work? How do I make this work as expected? > > > > maybe new? > > [snip] > > > not sure why... > > SystemCallError does not use Exception's initialize: > > rb_eSystemCallError = rb_define_class("SystemCallError", > rb_eStandardError); > rb_define_method(rb_eSystemCallError, "initialize", > syserr_initialize, -1); Yuck. Could it be altered to call super? Or would that cause some hideous side effect? Regards Dan PS - Sorry if this is a double post - google groups went goofy on me for a minute.