class Console::Output::Failure
A wrapper for outputting failure messages, which can include exceptions.
def call(subject = nil, *arguments, exception: nil, **options, &block)
@parameter options [Hash] Additional options to pass to the output.
@parameter exception [Exception] The exception to output.
@parameter arguments [Array] The arguments to output.
@parameter subject [String] The subject of the message.
The exception must be either the last argument or passed as an option.
def call(subject = nil, *arguments, exception: nil, **options, &block) if exception.nil? last = arguments.last if last.is_a?(Exception) options[:event] = Event::Failure.for(last) end elsif exception.is_a?(Exception) options[:event] = Event::Failure.for(exception) else # We don't know what this is, so we just pass it through: options[:exception] = exception end super(subject, *arguments, **options, &block) end
def initialize(output, **options)
def initialize(output, **options) super(output, **options) end