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

前端 未结 10 1601
-上瘾入骨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:51

    I was getting these errors when trying to load my test environment (via rake test or autotest) and the IRB suggestions didn't help. I ended up wrapping my entire test/test_helper.rb in a begin/rescue block and that fixed things up.

    begin
      class ActiveSupport::TestCase
        #awesome stuff
      end
    rescue => e
      puts e.backtrace
    end
    

提交回复
热议问题