Sha256: 7b10220b369b76a786af52ffa48910a47a2ba72b19cdaa6e52d863fbf791751d

Contents?: true

Size: 1.48 KB

Versions: 6

Compression:

Stored size: 1.48 KB

Contents

module Trepan
  class CatchCommand < OldCommand # :nodoc:
    self.allow_in_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.
        info_catch
      elsif not @match[2]
        # One arg given.
        if 'off' == excn
          Debugger.catchpoints.clear if 
            confirm("Delete all catchpoints? (y or n) ")
        else
          binding = @state.context ? get_binding : TOPLEVEL_BINDING
          unless debug_eval("#{excn}.is_a?(Class)", binding)
            print "Warning #{excn} is not known to be a Class\n"
          end
          Debugger.add_catchpoint(excn)
          print "Catch exception %s.\n", excn
        end
      elsif @match[2] != 'off'
        errmsg "Off expected. Got %s\n", @match[2]
      elsif Debugger.catchpoints.member?(excn)
        Debugger.catchpoints.delete(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\tsame as "info catch"
          cat[ch] <exception-name> [on|off]
\tIntercept <exception-name> when there would otherwise be no handler.
\tWith an "on" or "off", turn handling the exception on or off.
          cat[ch] off\tdelete all catchpoints
        }
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
rb8-trepanning-0.1.6 processor/command-ruby-debug/catchpoint.rb
rb8-trepanning-0.1.5 processor/command-ruby-debug/catchpoint.rb
rb8-trepanning-0.1.4 processor/command-ruby-debug/catchpoint.rb
rb8-trepanning-0.1.3 processor/command-ruby-debug/catchpoint.rb
rb8-trepanning-0.1.3-universal-ruby-1.9.2 processor/command-ruby-debug/catchpoint.rb
rb8-trepanning-0.1.3-universal-ruby-1.8.7 processor/command-ruby-debug/catchpoint.rb