Skip to content

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
def expression_backtrace(backtrace)
new_trace = []
backtrace.each do |line|
match = /(.*):([0-9]+):in/.match line
file, linenum = match[1], match[2].to_i
new_trace << line
if File.exist?(file)
expr = File.readlines(file)[linenum - 1]
expr.strip!
new_trace << "\tat expression: \"#{expr}\""
end
end
new_trace
end
def foo
raise # raise an error
end
def bar
foo # call foo in bar
end
def baz
bar # call bar in baz
end
begin
baz
rescue => e
puts expression_backtrace(e.backtrace)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.