Sha256: 7189df84fdc46dd9f70597d2162bf46103ed4573c3462ea6779ba7f4f473b2b4

Contents?: true

Size: 462 Bytes

Versions: 6

Compression:

Stored size: 462 Bytes

Contents

# frozen_string_literal: true

require_relative "base"

class ExceptionTracer < Tracer::Base
  def setup_tp
    TracePoint.new(:raise) do |tp|
      next if skip?(tp)

      exc = tp.raised_exception

      out tp,
          " #{colorize_magenta(exc.inspect)}",
          depth: caller.size - (1 + @depth_offset)
    rescue Exception => e
      p e
    end
  end

  def skip_with_pattern?(tp)
    super && !tp.raised_exception.inspect.match?(@pattern)
  end
end

Version data entries

6 entries across 6 versions & 2 rubygems

Version Path
tracer-0.2.2 lib/tracer/exception_tracer.rb
tracer-0.2.1 lib/tracer/exception_tracer.rb
tracer-0.2.0 lib/tracer/exception_tracer.rb
ruby_tracer-0.3.1 lib/ruby_tracer/exception_tracer.rb
ruby_tracer-0.3.0 lib/ruby_tracer/exception_tracer.rb
ruby_tracer-0.2.0 lib/ruby_tracer/exception_tracer.rb