From: Jim Freeze Date: 2002-04-08T11:07:00+09:00 Subject: Re: Exception instances... On Mon, Apr 08, 2002 at 10:33:27AM +0900, Sean Chittenden wrote: > I don't understand where the following warning is coming from: > > > ruby -w test_exeptions.rb > Start > test_exceptions.rb:14: warning: instance variable mesg not initialized > TestingError > Just testing... > Finish. > > > ### Begin: test_exceptions.rb > class TestingError < StandardError > attr_reader :uga > def initialize (booga) > @uga = booga puts "booga: #{booga}" ## => add this line > end > end # class TestingError > > begin > puts 'Start' > raise TestingError.new('booga?'), 'Just testing...' > rescue TestingError => reason > puts reason # This is line 14 > puts reason.uga > ensure > puts 'Finish.' > end > ### End: test_exceptions.rb > After adding the line above, you will notice that TestingError is called again with "Just testing..." as the argument, thus reason never sees 'booga?'. Someone else smarter will have to answer why. > I'm pulling this example from the Pick-axe and ... I'm not sure what > the problem is. How can I get TestingError#uga? Somehow I want to be > able to print out 'booga?' but I don't know where that info is getting > stashed. > > > ruby -v > ruby 1.6.7 (2002-03-27) [i386-freebsd4] > > -sc > > -- > Sean Chittenden -- Jim Freeze If only I had something clever to say for my comment... ~