Sha256: c511700162e3786667796536599c7845724e9a88dc4e620d8eba1f6828f3b6ae

Contents?: true

Size: 1.34 KB

Versions: 20

Compression:

Stored size: 1.34 KB

Contents

module Debugger
  class CatchCommand < Command # :nodoc:
    self.control = true

    def regexp
      /^\s* cat(?:ch)? 
           (?:\s+ (\S+))? 
           (?:\s+ (off))? \s* $/ix
    end

    def execute
      excn = @match[1] 
      if not excn
        # No args given.
        errmsg "Exception class must be specified for 'catch' command"
      elsif not @match[2]
        # One arg given.
        if 'off' == excn
          Debugger.catchpoints.clear
        else
          binding = @state.context ? get_binding : TOPLEVEL_BINDING
          unless debug_eval("#{excn}.is_a?(Class)", binding)
            print_msg "Warning #{excn} is not known to be a Class"
          end
          Debugger.add_catchpoint(excn)
          print_catchpoint_set(excn)
        end
      elsif @match[2] != 'off'
        errmsg "Off expected. Got %s\n", @match[2]
      elsif Debugger.catchpoints.member?(excn)
        Debugger.catchpoints.delete(excn)
        print_catchpoint_set(excn)
        #print "Catch for exception %s removed.\n", excn
      else
        errmsg "Catch for exception %s not found.\n", excn
      end
    end
    
    class << self
      def help_command
        'catch'
      end

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

Version data entries

20 entries across 20 versions & 3 rubygems

Version Path
debugger-ide-0.0.2 lib/ruby-debug/commands/catchpoint.rb
ruby-debug-ide-0.4.17.beta13 lib/ruby-debug-ide/commands/catchpoint.rb
ruby-debug-ide-0.4.17.beta12 lib/ruby-debug-ide/commands/catchpoint.rb
ruby-debug-ide-0.4.17.beta9 lib/ruby-debug-ide/commands/catchpoint.rb
ruby-debug-ide-0.4.17.beta8 lib/ruby-debug/commands/catchpoint.rb
ruby-debug-ide-0.4.17.beta6 lib/ruby-debug/commands/catchpoint.rb
ruby-debug-ide-0.4.17.beta5 lib/ruby-debug/commands/catchpoint.rb
ruby-debug-ide-0.4.17.beta4 lib/ruby-debug/commands/catchpoint.rb
ruby-debug-ide-0.4.17.beta3 lib/ruby-debug/commands/catchpoint.rb
ruby-debug-ide-0.4.16 lib/ruby-debug/commands/catchpoint.rb
ruby-debug-ide-0.4.11 lib/ruby-debug/commands/catchpoint.rb
ruby-debug-ide-0.4.10 lib/ruby-debug/commands/catchpoint.rb
ruby-debug-ide19-0.4.12 lib/ruby-debug/commands/catchpoint.rb
ruby-debug-ide19-0.4.11 lib/ruby-debug/commands/catchpoint.rb
ruby-debug-ide19-0.4.10 lib/ruby-debug/commands/catchpoint.rb
ruby-debug-ide-0.4.9 lib/ruby-debug/commands/catchpoint.rb
ruby-debug-ide-0.4.8 lib/ruby-debug/commands/catchpoint.rb
ruby-debug-ide-0.4.7 lib/ruby-debug/commands/catchpoint.rb
ruby-debug-ide-0.4.6 lib/ruby-debug/commands/catchpoint.rb
ruby-debug-ide-0.4.5 lib/ruby-debug/commands/catchpoint.rb