Class: CSVPlusPlus::ErrorFormatter
- Inherits:
-
Object
- Object
- CSVPlusPlus::ErrorFormatter
- Extended by:
- T::Sig
- Defined in:
- lib/csv_plus_plus/error_formatter.rb
Overview
Handle any errors potentially thrown during compilation. This could be anything from a user error (for example calling with invalid csvpp code) to an error calling Google Sheets API or writing to the filesystem.
Instance Method Summary collapse
-
#handle_error(error) ⇒ Object
Nicely handle a given error.
-
#initialize(options:, runtime:) ⇒ ErrorFormatter
constructor
A new instance of ErrorFormatter.
Constructor Details
#initialize(options:, runtime:) ⇒ ErrorFormatter
Returns a new instance of ErrorFormatter.
15 16 17 18 |
# File 'lib/csv_plus_plus/error_formatter.rb', line 15 def initialize(options:, runtime:) @options = @runtime = runtime end |
Instance Method Details
#handle_error(error) ⇒ Object
Nicely handle a given error. How it’s handled depends on if it’s our error and if @options.verbose
24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/csv_plus_plus/error_formatter.rb', line 24 def handle_error(error) # make sure that we're on a newline (verbose mode will probably be in the middle of printing a benchmark) puts("\n\n") if @options.verbose case error when ::CSVPlusPlus::Error::Error handle_internal_error(error) when ::Google::Apis::ClientError handle_google_error(error) else unhandled_error(error) end end |