How do I get ruby to print a full backtrace instead of a truncated one?

前端 未结 10 1593
-上瘾入骨i
-上瘾入骨i 2020-12-12 12:00

When I get exceptions, it is often from deep within the call stack. When this happens, more often than not, the actual offending line of code is hidden from me:



        
10条回答
  •  暖寄归人
    2020-12-12 12:49

    This produces the error description and nice clean, indented stacktrace:

    begin               
     # Some exception throwing code
    rescue => e
      puts "Error during processing: #{$!}"
      puts "Backtrace:\n\t#{e.backtrace.join("\n\t")}"
    end
    

提交回复
热议问题