Sha256: 065f4a6c8b068a96c3364239ebd110edc71cfdc59f08a20de772e8e84eb32d1b
Contents?: true
Size: 1.61 KB
Versions: 24
Compression:
Stored size: 1.61 KB
Contents
module Rollbar class Notifier class TraceWithBindings # :nodoc: attr_reader :frames, :exception_frames def initialize reset end def reset @frames = [] @exception_frames = [] @exception_signature = nil end def enable reset trace_point.enable if defined?(TracePoint) end def disable trace_point.disable if defined?(TracePoint) end private def exception_signature(trace) # use the exception backtrace to detect reraised exception. trace.raised_exception.backtrace.first end def detect_reraise(trace) @exception_signature == exception_signature(trace) end def trace_point return unless defined?(TracePoint) @trace_point ||= TracePoint.new(:call, :return, :b_call, :b_return, :c_call, :c_return, :raise) do |tp| case tp.event when :call, :b_call, :c_call, :class frames.push frame(tp) when :return, :b_return, :c_return, :end frames.pop when :raise unless detect_reraise(tp) # ignore reraised exceptions @exception_frames = @frames.dup # may be possible to optimize better than #dup @exception_signature = exception_signature(tp) end end end end def frame(trace) { :binding => trace.binding, :defined_class => trace.defined_class, :method_id => trace.method_id, :path => trace.path, :lineno => trace.lineno } end end end end
Version data entries
24 entries across 24 versions & 1 rubygems