From: Niklas Frykholm Date: 2001-10-23T19:12:30+09:00 Subject: [ruby-talk:23033] Re: Error in Programming Ruby and patch suggestion for ruby On Tue, Oct 23, 2001 at 05:24:37PM +0900, ts wrote: > N> + StringValue(argv[0]); > N> + rb_iv_set(self, "mesg", argv[0]); > Seems for me similar to Exception#message, no ? > > http://ruby-talk.com/17066 Hmmm... looking at this again I don't think RCR #22 (already implemented) addresses the issue. And matz has rejected RCR #21... If the problem is that the exceptions become mutable, it is OK for me to first make a clone and then do rb_iv_set('mesg', argv[0]). My concern is that I want to write an exception class which takes something other than a message string in the initializer, but still can be used with raise object, "message" It seems to me that the semantics for raise should be that it should take an exception object and a message. Not an exception and arguments to its initializer... because that will only allow exceptions with single argument initializers. Today, I can only think of ugly solutions (the ones in my previous message). Here is another ugly solution: class RetryError < StandardError attr_reader :ok def initialize(ok) if instance_variables.include?('@ok') super(ok) else @ok = ok end end end And another: class RetryError < StandardError attr_reader :ok def initialize(ok, msg = "") super(msg) @ok = ok end def exception(*arg) if arg.size==0 return self else return type.new(@ok, *arg) end end end // Niklas