Issue #13557 has been updated by byroot (Jean Boussier).
@ko1 all the same use cases arrays of strings are currently used for:
E.g. raising an error with an existing backtrace:
```ruby
raise NicerError, "some message", original_error.backtrace_locations
```
Or with some frames skipped:
```ruby
raise SomeError, "some message", caller_locations(2) # skip 2 frames
```
Creating an exception with a thread backtrace:
```ruby
async_error = SomeError.new("thread timed out")
async_error.set_backtrace(other_thread.backtrace_locations)
report(async_error)
```
And probably plenty others I'm not thinking of. This is only an improved version of
passing `set_backtrace(exc.backtrace)`.
----------------------------------------
Feature #13557: there's no way to pass backtrace locations as a massaged backtrace
https://bugs.ruby-lang.org/issues/13557#change-107188
* Author: sylvain.joyeux (Sylvain Joyeux)
* Status: Open
----------------------------------------
When re-raising exceptions, it is sometimes useful to "massage" the backtrace
(especially in DSLs).
There is currently no way to do it using only backtrace locations. This causes the new
exception to have #backtrace_locations return nil, and thus makes backtrace_locations
unreliable as a whole.
Example:
~~~ruby
def test
raise ArgumentError, "", caller_locations
end
begin
test
rescue ArgumentError => e
p e.backtrace_locations
end
~~~
attempting to pass `caller_location` to `Kernel#raise` in the `test` method fails with
``bla.rb:2:in `set_backtrace': backtrace must be Array of String (TypeError)``
--
https://bugs.ruby-lang.org/