Actions
Misc #15568
openTracePoint(:raise)#parameters raises RuntimeError
Misc #15568:
TracePoint(:raise)#parameters raises RuntimeError
Status:
Open
Assignee:
-
Description
Currently trying to get the trace.parameters
of a method in a raise
event will lead to a RuntimeError. I would contend that it should not, and that it would be perfectly valid to ask for the parameters in the case of an exception.
The reason I do this is to see the arguments at the time of exception:
def extract_args(trace)
trace.parameters.map(&:last).to_h do |name|
[name, trace.binding.eval(name.to_s)]
end
end
I've noticed that I can technically "cheat" and get these same values like this:
def extract_args(trace)
trace.binding.eval('local_variables').to_h do |name|
[name, trace.binding.eval(name.to_s)]
end
end
Having the ability to get the parameters in a raise
context would be very useful for debugging.
I'm tempted to also suggest TracePoint#local_variables
as it would provide additional context in a more exposed way than TracePoint#binding.eval('local_variables')
Actions