https://bugs.ruby-lang.org/https://bugs.ruby-lang.org/favicon.ico?17113305112017-05-15T11:31:02ZRuby Issue Tracking SystemRuby master - Bug #13564: Exception message managementhttps://bugs.ruby-lang.org/issues/13564?journal_id=648172017-05-15T11:31:02ZEregon (Benoit Daloze)
<ul></ul><p>I think using Exception#cause for this would be a better way to address this problem.<br>
However, there is a long-standing bug of the cause not being shown in Exception#inspect and neither by the top-level handler: <a href="https://bugs.ruby-lang.org/issues/9918" class="external">https://bugs.ruby-lang.org/issues/9918</a></p>
<p><a class="user active user-mention" href="https://bugs.ruby-lang.org/users/17">@ko1 (Koichi Sasada)</a>: Could you share your use-case? Modifying an exception message in ensure seems unusual to me.<br>
In the test_gem_gem_runner.rb, it seems <code>rescue Exception</code> would be more intuitive to handle this (but it has the same problem about modifying the message).</p>
<p>Otherwise I think 1-1 + 2 is the best compromise.</p> Ruby master - Bug #13564: Exception message managementhttps://bugs.ruby-lang.org/issues/13564?journal_id=648432017-05-16T02:02:45Zko1 (Koichi Sasada)
<ul></ul><p>On 2017/05/15 20:31, <a href="mailto:eregontp@gmail.com" class="email">eregontp@gmail.com</a> wrote:</p>
<blockquote>
<p>I think using Exception#cause for this would be a better way to address this problem.<br>
However, there is a long-standing bug of the cause not being shown in Exception#inspect and neither by the top-level handler: <a href="https://bugs.ruby-lang.org/issues/9918" class="external">https://bugs.ruby-lang.org/issues/9918</a></p>
</blockquote>
<p>I agree it is one solution. However, to make sure transparency (for<br>
<code>rescue</code> clause which catch the exception later) we need to provide same<br>
error class (<code>$!.class</code>).</p>
<blockquote>
<p><a class="user active user-mention" href="https://bugs.ruby-lang.org/users/17">@ko1 (Koichi Sasada)</a>: Could you share your use-case? Modifying an exception message in ensure seems unusual to me.<br>
In the test_gem_gem_runner.rb, it seems <code>rescue Exception</code> would be more intuitive to handle this (but it has the same problem about modifying the message).</p>
</blockquote>
<p>My usage is a bit strange. I want to know the status about just before<br>
suspicious code (<code>require 'rubygems/gem_runner'</code>) and just after this<br>
line if $! is not nil. Usually we can show such information on STDERR<br>
but test framework (test-all with parallel option) hides all of STDERR<br>
output so that we need to show via Exception message.</p>
<p>I think such usage is not so frequent so that</p>
<blockquote>
<p>Otherwise I think 1-1 + 2 is the best compromise.</p>
</blockquote>
<p>I think (1) without (2) (with [Feature <a class="issue tracker-2 status-1 priority-4 priority-default" title="Feature: Exception#cause should be shown in output and #inspect (Open)" href="https://bugs.ruby-lang.org/issues/9918">#9918</a>]) is acceptable.</p>
<h2>Thanks,<br>
Koichi</h2>
<p>// SASADA Koichi at atdot dot net</p> Ruby master - Bug #13564: Exception message managementhttps://bugs.ruby-lang.org/issues/13564?journal_id=657912017-07-14T09:01:43Zmatz (Yukihiro Matsumoto)matz@ruby.or.jp
<ul></ul><p>I understand the principle. But I think it's a programmer's fault to modify the string.<br>
I don't think it's worth prohibiting (and making implementation more complex).</p>
<p>Matz.</p> Ruby master - Bug #13564: Exception message managementhttps://bugs.ruby-lang.org/issues/13564?journal_id=657962017-07-14T09:20:42Znaruse (Yui NARUSE)naruse@airemix.jp
<ul></ul><p>Now we have Exception#cause.<br>
Therefore it should be</p>
<pre><code class="ruby syntaxhl" data-language="ruby"><span class="k">begin</span>
<span class="k">raise</span> <span class="s1">'foo'</span>
<span class="k">ensure</span>
<span class="k">raise</span> <span class="s1">'bar'</span>
<span class="k">end</span>
</code></pre> Ruby master - Bug #13564: Exception message managementhttps://bugs.ruby-lang.org/issues/13564?journal_id=800862019-07-26T15:21:04Zjeremyevans0 (Jeremy Evans)merch-redmine@jeremyevans.net
<ul><li><strong>Status</strong> changed from <i>Open</i> to <i>Rejected</i></li></ul>