Class: Toys::CLI::DefaultErrorHandler
- Inherits:
-
Object
- Object
- Toys::CLI::DefaultErrorHandler
- Defined in:
- lib/toys/cli.rb
Overview
A basic error handler that prints out captured errors to a stream or a logger.
Instance Method Summary collapse
-
#call(error) ⇒ Object
The error handler routine.
-
#initialize(output = $stderr) ⇒ DefaultErrorHandler
constructor
Create an error handler.
Constructor Details
#initialize(output = $stderr) ⇒ DefaultErrorHandler
Create an error handler.
284 285 286 |
# File 'lib/toys/cli.rb', line 284 def initialize(output = $stderr) @terminal = Utils::Terminal.new(output: output) end |
Instance Method Details
#call(error) ⇒ Object
The error handler routine. Prints out the error message and backtrace.
293 294 295 296 297 |
# File 'lib/toys/cli.rb', line 293 def call(error) @terminal.puts(cause_string(error.cause)) @terminal.puts(context_string(error), :bold) -1 end |