Forum: Ruby Annotated Exception (a la Ruby Treasures)

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
unknown (Guest)
on 2006-05-28 03:15
(Received via mailing list)
Anyone remember Ruby Treasures? Well I was browsing thru some old Ruby
Treasures code (written by Paul B. BTW) and I came across a couple
implementations for adding annotations to Exceptions. These worked by
wrapping special blocks around a raise call. The syntax of those
implemenations didn't come off well though, but I started wondering if
something like that would be useful if it were part of the 'begin' call
instead. Eg.

  def foo
    begin 'playing with Ruby'
      # . . .
      begin 'doing some silly things'
        # . . .
        raise RuntimeError
      end
    end
  end

Resulting in somthing like:

  => test.rb:7 RuntimeError: RuntimeError
            began -- doing some silly things
            began -- playing with Ruby
            from test.rb:2:in `foo'
            from test.rb:2

Just a thought,

T.
This topic is locked and can not be replied to.