Class: Byebug::CatchCommand
- Includes:
- Helpers::EvalHelper
- Defined in:
- lib/byebug/commands/catch.rb
Overview
Implements exception catching.
Enables the user to catch unhandled assertion when they happen.
Instance Attribute Summary
Attributes inherited from Command
Class Method Summary collapse
Instance Method Summary collapse
Methods included from Helpers::EvalHelper
#error_eval, #multiple_thread_eval, #separate_thread_eval, #silent_eval, #warning_eval
Methods inherited from Command
#arguments, columnize, #context, #frame, help, #initialize, match, to_s
Methods included from Helpers::StringHelper
#camelize, #deindent, #prettify
Constructor Details
This class inherits a constructor from Byebug::Command
Class Method Details
.description ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/byebug/commands/catch.rb', line 21 def self.description <<-DESCRIPTION cat[ch][ (off|<exception>[ off])] #{short_description} catch -- lists catchpoints catch off -- deletes all catchpoints catch <exception> -- enables handling <exception> catch <exception> off -- disables handling <exception> DESCRIPTION end |
.regexp ⇒ Object
17 18 19 |
# File 'lib/byebug/commands/catch.rb', line 17 def self.regexp /^\s* cat(?:ch)? (?:\s+(\S+))? (?:\s+(off))? \s*$/x end |
.short_description ⇒ Object
34 35 36 |
# File 'lib/byebug/commands/catch.rb', line 34 def self.short_description "Handles exception catchpoints" end |
Instance Method Details
#execute ⇒ Object
38 39 40 41 42 43 44 45 46 |
# File 'lib/byebug/commands/catch.rb', line 38 def execute return info unless @match[1] return @match[1] == "off" ? clear : add(@match[1]) unless @match[2] return errmsg pr("catch.errors.off", off: cmd) unless @match[2] == "off" remove(@match[1]) end |