https://redmine.ruby-lang.org/https://redmine.ruby-lang.org/favicon.ico?17113305112021-06-16T19:46:41ZRuby Issue Tracking SystemRuby master - Feature #14835: Support TracePoint#raised_exception on non-:raise eventshttps://redmine.ruby-lang.org/issues/14835?journal_id=925432021-06-16T19:46:41Zjeremyevans0 (Jeremy Evans)merch-redmine@jeremyevans.net
<ul><li><strong>Tracker</strong> changed from <i>Bug</i> to <i>Feature</i></li><li><strong>Subject</strong> changed from <i>Impossible to know whether an exception was rescued or not using TracePoint</i> to <i>Support TracePoint#raised_exception on non-:raise events</i></li><li><strong>ruby -v</strong> deleted (<del><i>ruby 2.6.0preview2 (2018-05-31 trunk 63539) [x86_64-darwin17]</i></del>)</li><li><strong>Backport</strong> deleted (<del><i>2.3: UNKNOWN, 2.4: UNKNOWN, 2.5: UNKNOWN</i></del>)</li></ul><p>I looked into this, and with the current TracePoint design, it does not appear possible. For <code>:raise</code> events, the <code>raised_exception</code> is stored in <code>trace_args->data</code>. This is the same location that the return value is stored for <code>:return</code>, <code>:c_return</code>, and <code>:b_return</code> events. To change this, we would have to modify <code>rb_trace_arg_struct</code> to support additional space for storing the exception in the non-<code>:raise</code> case, and I'm not sure at the point of <code>:return</code> (or <code>:c_return</code>/<code>:b_return</code>) if we can get the exception.</p>
<p><code>TracePoint#raised_exception</code> is documented to only work for <code>:raise</code> events and not other events. So the current behavior is not a bug. I agree that there may be cases where <code>raised_exception</code> would be useful in other events. So I'm switching to feature request, though I don't know if it is feasible to implement such a feature.</p> Ruby master - Feature #14835: Support TracePoint#raised_exception on non-:raise eventshttps://redmine.ruby-lang.org/issues/14835?journal_id=950552021-12-02T20:14:18Zko1 (Koichi Sasada)
<ul><li><strong>Status</strong> changed from <i>Open</i> to <i>Feedback</i></li></ul><p>Sorry I can't understand the request.<br>
Could you explain more?</p> Ruby master - Feature #14835: Support TracePoint#raised_exception on non-:raise eventshttps://redmine.ruby-lang.org/issues/14835?journal_id=951352021-12-04T06:49:15Ztagomoris (Satoshi Tagomori)tagomoris@gmail.com
<ul></ul><p>We cannot know how "return" events are triggered. It can be triggered by usual returns (return values), and also be triggered by raised exceptions (does not return values).<br>
This also makes it impossible to know where the raised exception was rescued.</p>
<p>If the "return" event contains exceptions (as <code>raised_exception</code>) when it is triggered by raised events, we can distinguish "return" events, by usual returns, or by raised exceptions. That is my request.</p>
<p>Currently, calling <code>raised_exception</code> method on "return" event causes the exception below:</p>
<pre><code><internal:trace_point>:338:in `raised_exception': not supported by this event (RuntimeError)
from /Users/tagomoris/hoge.rb:20:in `block in <main>'
from /Users/tagomoris/hoge.rb:9:in `caller_with_rescue'
from /Users/tagomoris/hoge.rb:26:in `<main>'
</code></pre>