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
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:
#<Binding:0xb7e31a5c>
"value of a"
["a"]
路路路
--
vjoel : Joel VanderWerf : path berkeley edu : 510 665 3407
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.
Note, that you can view the stack trace already with standard means:
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
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
Yes indeed and it is not possible with standart ruby at the moment.
It just does what you want and it also automatically starts a post mortem
debugger when an unhandled exception terminats the program. So it is
easy to inspect the values.
路路路
--
Best regards, emailto: scholz at scriptolutions dot com
Lothar Scholz http://www.ruby-ide.com
CTO Scriptolutions Ruby, PHP, Python IDE 's