Class: DEBUGGER__::CatchBreakpoint

Inherits:
Breakpoint show all
Defined in:
lib/debug/breakpoint.rb

Instance Attribute Summary collapse

Attributes inherited from Breakpoint

#key, #skip_src

Instance Method Summary collapse

Methods inherited from Breakpoint

#delete, #deleted?, #disable, #duplicable?, #enable, #enabled?, #generate_label, #oneshot?, #safe_eval, #skip_path?, #suspend

Methods included from Color

#color_pp, #colored_inspect, #colorize, #colorize_blue, #colorize_code, #colorize_cyan, #colorize_dim, #colorize_magenta, #irb_colorize, #with_inspection_error_guard

Methods included from SkipPathHelper

#skip_config_skip_path?, #skip_internal_path?, #skip_location?, #skip_path?

Constructor Details

#initialize(pat, cond: nil, command: nil, path: nil) ⇒ CatchBreakpoint

Returns a new instance of CatchBreakpoint.



305
306
307
308
309
310
311
# File 'lib/debug/breakpoint.rb', line 305

def initialize pat, cond: nil, command: nil, path: nil
  @pat = pat.freeze
  @key = [:catch, @pat].freeze
  @last_exc = nil

  super(cond, command, path)
end

Instance Attribute Details

#last_excObject (readonly)

Returns the value of attribute last_exc.



303
304
305
# File 'lib/debug/breakpoint.rb', line 303

def last_exc
  @last_exc
end

Instance Method Details

#descriptionObject



337
338
339
# File 'lib/debug/breakpoint.rb', line 337

def description
  "#{@last_exc.inspect} is raised."
end

#setupObject



313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
# File 'lib/debug/breakpoint.rb', line 313

def setup
  @tp = TracePoint.new(:raise){|tp|
    exc = tp.raised_exception
    next if SystemExit === exc
    next if skip_path?(tp.path)

    next if !safe_eval(tp.binding, @cond) if @cond
    should_suspend = false

    exc.class.ancestors.each{|cls|
      if @pat === cls.name
        should_suspend = true
        @last_exc = exc
        break
      end
    }
    suspend if should_suspend
  }
end

#to_sObject



333
334
335
# File 'lib/debug/breakpoint.rb', line 333

def to_s
  "#{generate_label("Catch")} #{@pat.inspect}"
end