Catching line numbers in ruby exceptions

后端 未结 5 555
孤独总比滥情好
孤独总比滥情好 2021-01-30 16:21

Consider the following ruby code

test.rb:

begin

  puts
  thisFunctionDoesNotExist
  x = 1+1
rescue Exception => e
  p e
end

For deb

5条回答
  •  攒了一身酷
    2021-01-30 16:52

    Throwing my $0.02 in on this old thread-- here's a simple solution that maintains all the original data:

    print e.backtrace.join("\n")
    

提交回复
热议问题