From: Joel VanderWerf Date: 2005-08-11T14:47:11+09:00 Subject: Re: Bindings at the time of Exceptions Adam Sanderson wrote: > I always thought it would be neat to be able to get the binding at the > time an exception was raised so that one could see the state the stack > was in when an exception occurred. > > It would be nice list the local variables and values at the time of the > exception for instance. Can anyone think of some trickery to do this? > I think it would be of great use for debugging and whatnot, and > massive points for cool ruby hackery ;) > .adam sanderson > No trickery, but you do have to have the cooperation of the code which raises: def foo a = "value of a" raise StandardError, binding end def bar foo rescue => e return e.message end b = bar p b p eval("a", b) p eval("local_variables", b) __END__ output: # "value of a" ["a"] -- vjoel : Joel VanderWerf : path berkeley edu : 510 665 3407