From: eregontp@...
Date: 2019-03-22T22:41:09+00:00
Subject: [ruby-core:91951] [Ruby trunk Bug#15558] Should Exception#exception	copy the backtrace?

Issue #15558 has been updated by Eregon (Benoit Daloze).


@nobu and other MRI committers: what do you think?

It's somewhat inconsistent with Exception#clone which does copy the backtrace.

Would it make sense to follow JRuby and TruffleRuby's behavior, by copying the backtrace too, here?

----------------------------------------
Bug #15558: Should Exception#exception copy the backtrace?
https://bugs.ruby-lang.org/issues/15558#change-77283

* Author: Eregon (Benoit Daloze)
* Status: Open
* Priority: Normal
* Assignee: 
* Target version: 
* ruby -v: ruby 2.6.0p0 (2018-12-25 revision 66547) [x86_64-linux]
* Backport: 2.4: UNKNOWN, 2.5: UNKNOWN, 2.6: UNKNOWN
----------------------------------------
Currently it does not on MRI:
```
ruby -e 'begin raise "foo"; rescue => e; c=e.exception "bar"; p c.backtrace; end'
nil
```

But it does on JRuby 9.2.5.0 and TruffleRuby 1.0.0-rc11:
```
truffleruby -e 'begin raise "foo"; rescue => e; c=e.exception "bar"; p e.backtrace; end'
["-e:1:in `<main>'"]
```

This means in some cases, code needs about this difference such as in
https://github.com/asciidoctor/asciidoctor/blob/41da20a47a8da96966ef3ec1c2f509e07e7920e3/lib/asciidoctor.rb#L1322-L1338
More context in:
https://github.com/oracle/truffleruby/issues/1542#issuecomment-456850066



-- 
https://bugs.ruby-lang.org/

Unsubscribe: <mailto:ruby-core-request@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>