Sha256: 67991418516e336825b400dd0061c3a9f30de00c5484fb194a7fc6202292acf1

Contents?: true

Size: 1.48 KB

Versions: 57

Compression:

Stored size: 1.48 KB

Contents

module Debugger
  class CatchCommand < Command # :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

57 entries across 55 versions & 10 rubygems

Version Path
ruby-debug-0.11.0 cli/ruby-debug/commands/catchpoint.rb
logstash-output-icinga-1.1.0 vendor/jruby/1.9/gems/ruby-debug-0.10.6/cli/ruby-debug/commands/catchpoint.rb
ruby-debug-0.10.6 cli/ruby-debug/commands/catchpoint.rb
debugger-1.6.7 lib/ruby-debug/commands/catchpoint.rb
debugger-1.6.6 lib/ruby-debug/commands/catchpoint.rb
debugger-1.6.5 lib/ruby-debug/commands/catchpoint.rb
debugger-1.6.4 lib/ruby-debug/commands/catchpoint.rb
debugger-1.6.3 lib/ruby-debug/commands/catchpoint.rb
ruby-debug-0.10.5.rc9 cli/ruby-debug/commands/catchpoint.rb
debugger-1.6.2 lib/ruby-debug/commands/catchpoint.rb
ruby-debug-0.10.5.rc8 cli/ruby-debug/commands/catchpoint.rb
candlepin-api-0.4.0 bundle/ruby/gems/debugger-1.6.1/lib/ruby-debug/commands/catchpoint.rb
candlepin-api-0.4.0 bundle/ruby/1.8/gems/ruby-debug-0.10.4/cli/ruby-debug/commands/catchpoint.rb
candlepin-api-0.4.0 bundle/ruby/1.9.1/gems/debugger-1.6.1/lib/ruby-debug/commands/catchpoint.rb
ruby-debug-0.10.5.rc7 cli/ruby-debug/commands/catchpoint.rb
ruby-debug-0.10.5.rc5 cli/ruby-debug/commands/catchpoint.rb
ruby-debug-0.10.5.rc4 cli/ruby-debug/commands/catchpoint.rb
debugger-1.6.1 lib/ruby-debug/commands/catchpoint.rb
debugger-1.6.0 lib/ruby-debug/commands/catchpoint.rb
debugger2-1.0.0.beta2 lib/ruby-debug/commands/catchpoint.rb