Class: Debugger::CatchCommand

Inherits:
Command
  • Object
show all
Defined in:
lib/ruby-debug/commands/catchpoint.rb

Overview

:nodoc:

Constant Summary

Constants inherited from Command

Debugger::Command::DEF_OPTIONS

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Command

commands, #find, inherited, #initialize, load_commands, #match, method_missing, options

Constructor Details

This class inherits a constructor from Debugger::Command

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Debugger::Command

Class Method Details

.help(cmd) ⇒ Object



28
29
30
31
32
33
# File 'lib/ruby-debug/commands/catchpoint.rb', line 28

def help(cmd)
  %{
    cat[ch]\t\t\tshow catchpoint
    cat[ch] <an Exception>\tset catchpoint to an exception
  }
end

.help_commandObject



24
25
26
# File 'lib/ruby-debug/commands/catchpoint.rb', line 24

def help_command
  'catch'
end

Instance Method Details

#executeObject



9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/ruby-debug/commands/catchpoint.rb', line 9

def execute
  exception_class_name = @match[1]
  unless exception_class_name
    errmsg "Exception class must be specified for 'catch' command"
  else
    binding = @state.context ? get_binding : TOPLEVEL_BINDING
    unless debug_eval("#{exception_class_name}.is_a?(Class)", binding)
      print_msg "Warning #{exception_class_name} is not known to be a Class"
    end
    Debugger.add_catchpoint(exception_class_name)
    print_catchpoint_set(exception_class_name)
  end
end

#regexpObject



5
6
7
# File 'lib/ruby-debug/commands/catchpoint.rb', line 5

def regexp
  /^\s* cat(?:ch)? (?:\s+(.+))? $/x
end