Jacob Fugal said:
> On 10/25/05, Yohanes Santoso <ysantoso-rubycore / jenny-gnome.dyndns.org>
> wrote:
>> Would you accept a patch to provide nested Exception?

> Or am I misunderstanding your question?

Generally you want nested exceptions to when locally handling a low level
exception (e.g. File Not Found) and wish to rethrow it as a more specific
exception (e.g. Config File Not Found).  By chaining ConfigFileNotFound
exception to the FileNotFound exception, you preserve the original reason
(and call stack) for the exception while adding addition interpretation as
it is passed up the call stack.

I did something similar recently in a mock class that needed to translate
a regular Exception into an assertion failed exception, but not lose where
the original point in the code that the exception was thrown.  The
following seemed to work for me:

  def mock_wrap
    yield
  rescue Test::Unit::AssertionFailedError => ex
    raise Test::Unit::AssertionFailedError,
      "in mock '#{@mock_name}': #{ex.message}",
      ex.backtrace
  end

-- 
-- Jim Weirich     jim / weirichhouse.org    http://onestepback.org
-----------------------------------------------------------------
"Beware of bugs in the above code; I have only proved it correct,
not tried it." -- Donald Knuth (in a memo to Peter van Emde Boas)