lib/backtracer.rb in backtracer-0.2.0 vs lib/backtracer.rb in backtracer-0.2.1

- old
+ new

@@ -1,20 +1,30 @@ # this one display full BT with code, at the end [no performance loss] -SCRIPT_LINES__ = {} + +require File.dirname(__FILE__) + "/shared" +require 'sane' + at_exit { - puts "==== " - if $! - backtrace_with_code = $!.backtrace.map{|bt| - file, line, junk = bt.split(":") - line = line.to_i - 1 - actual_file = SCRIPT_LINES__[file] - actual_line = actual_file[line] if actual_file - "#{bt}\n\t#{actual_line.strip if actual_line}" - } - puts backtrace_with_code - puts "====" - else - puts "(no exception to backtrace)" - end - + if $! + puts "==== " + bt2 = $!.backtrace + backtrace_with_code = $!.backtrace.map{ |bt_line| + if OS.windows? && bt_line[1..1] == ':' + #["C", "/dev/ruby/allgems/lib/allgems/GemWorker.rb", "91", "in `unpack'"] + drive, file, line, junk = bt_line.split(":") + file = drive + ":" + file + else + file, line, junk = bt_line.split(":") + end + line = line.to_i +# line -= 1 unless line == 0 # not sure if needed + actual_line = Tracer.get_line(file, line) + "#{bt_line}\n\t#{actual_line.strip if actual_line}" + } + puts backtrace_with_code + puts "====" + else + puts "(no exception found to backtrace)" + end + exit! }