From: jayce@... (Jayce Piel) Date: 2002-04-05T01:52:02+09:00 Subject: Re: Test the result of an initialization ? David Alan Black wrote: > > > class ArchiveFile > > > def initialize(filename) > > > if not File.stat(filename).file? > > > raise "#{filename} is not a valid file" > > > end > > > end > > > end > > > > Hmmm... > > But the fact remains... Where must I put the catch ? > > You'd want to include a rescue clause for the code where you try > to create the object: > > class Thing > def initialize > raise > end > end > > begin > t = Thing.new > rescue > puts "Caught exception" > end Ok, so that is near to the same problem that testing argument before the call to #new... :-/ By putting begin/rescue code around all call to #new, the code begins to be unreadable... I will try a begin/rescue inside the #new rounding a call to the original #new... -- Jayce Piel ( jayce@mosx.net ) Site Web sur MacOS X (Server) en fran�ais : Pourquoi il ne faut pas activer le compte root ? R�ponse :