Class: Console::Output::Failure
- Defined in:
- lib/console/output/failure.rb
Overview
A wrapper for outputting failure messages, which can include exceptions.
Instance Attribute Summary
Attributes inherited from Wrapper
Instance Method Summary collapse
-
#call(subject = nil, *arguments, exception: nil, **options, &block) ⇒ Object
The exception must be either the last argument or passed as an option.
-
#initialize(output, **options) ⇒ Failure
constructor
Create a new failure output wrapper.
Methods inherited from Wrapper
#The output to delegate to.=, #last_output, #verbose!
Constructor Details
#initialize(output, **options) ⇒ Failure
Create a new failure output wrapper.
14 15 16 |
# File 'lib/console/output/failure.rb', line 14 def initialize(output, **) super(output, **) end |
Instance Method Details
#call(subject = nil, *arguments, exception: nil, **options, &block) ⇒ Object
The exception must be either the last argument or passed as an option.
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/console/output/failure.rb', line 25 def call(subject = nil, *arguments, exception: nil, **, &block) if exception.nil? last = arguments.last if last.is_a?(Exception) [:event] = Event::Failure.for(last) end elsif exception.is_a?(Exception) [:event] = Event::Failure.for(exception) else # We don't know what this is, so we just pass it through: [:exception] = exception end super(subject, *arguments, **, &block) end |