Sha256: 105409aa9dbd20845a7ef98d97bd58d5f1a0477b482731fc36c5d8f9df52502d

Contents?: true

Size: 1.2 KB

Versions: 2

Compression:

Stored size: 1.2 KB

Contents

# this one display full BT with code, at the end [no performance loss]
require 'rbconfig'
WINDOZE = Config::CONFIG['host_os'] =~ /mswin|mingw/

require File.dirname(__FILE__) + "/shared"

at_exit {
  if $! && !$!.is_a?(SystemExit) # SystemExit's are normal, not exceptional
    puts "\n     " + $!.inspect + ' ' + $!.to_s
    bt2 = $!.backtrace
    backtrace_with_code = $!.backtrace.map{ |bt_line|
      next if bt_line.include? 'bin/backtracer' # binary lines...
      if WINDOZE && bt_line[1..1] == ':'
        
        drive, file, line, junk = bt_line.split(":")
	#["C", "/dev/ruby/allgems/lib/allgems/GemWorker.rb", "91", "in `unpack'"]              
        file = drive + ":" + file
      else
        file, line, junk = bt_line.split(":")
      end
      line = line.to_i
      actual_line = Tracer.get_line(file, line)

      "#{bt_line}\n\t#{actual_line.strip if actual_line}"
    }.compact
    puts backtrace_with_code
    puts
    puts 'original backtrace:'
  else
    puts "(backtracer: no exception found to backtrace)" if $VERBOSE
  end
  # exit! TODO I guess do this once ours isn't *so* ugly
  # I'm not sure it's safe to do that, in case there are other at_exit's [?]
  # TODO compare with that fella xray
}

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
backtracer-0.5.1 lib/backtracer.rb
backtracer-0.5.0 lib/backtracer.rb