Class: TTY::Option::ErrorAggregator
- Inherits:
-
Object
- Object
- TTY::Option::ErrorAggregator
- Includes:
- Inflection
- Defined in:
- lib/tty/option/error_aggregator.rb
Instance Attribute Summary collapse
-
#errors ⇒ Object
readonly
Collected errors.
Instance Method Summary collapse
-
#call(error, message = nil) ⇒ Object
Record or raise an error.
-
#initialize(errors = [], raise_on_parse_error: false) ⇒ ErrorAggregator
constructor
A new instance of ErrorAggregator.
Methods included from Inflection
dasherize, demodulize, underscore
Constructor Details
#initialize(errors = [], raise_on_parse_error: false) ⇒ ErrorAggregator
Returns a new instance of ErrorAggregator.
13 14 15 16 |
# File 'lib/tty/option/error_aggregator.rb', line 13 def initialize(errors = [], raise_on_parse_error: false) @errors = errors @raise_on_parse_error = raise_on_parse_error end |
Instance Attribute Details
#errors ⇒ Object (readonly)
Collected errors
11 12 13 |
# File 'lib/tty/option/error_aggregator.rb', line 11 def errors @errors end |
Instance Method Details
#call(error, message = nil) ⇒ Object
Record or raise an error
24 25 26 27 28 29 30 31 32 |
# File 'lib/tty/option/error_aggregator.rb', line 24 def call(error, = nil) if error.is_a?(Class) error = .nil? ? error.new : error.new() end raise(error) if @raise_on_parse_error @errors << error end |