Project

General

Profile

Actions

Feature #13557

closed

there's no way to pass backtrace locations as a massaged backtrace

Added by sylvain.joyeux (Sylvain Joyeux) over 7 years ago. Updated 9 months ago.

Status:
Closed
Assignee:
-
Target version:
-
[ruby-core:81102]

Description

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:

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)

Actions

Also available in: Atom PDF

Like1
Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0