Exception: Reading::Error
- Defined in:
- lib/reading/errors.rb
Overview
The base error class, which provides flexible error handling.
Direct Known Subclasses
ConfigError, FileError, InvalidDateError, InvalidHeadError, InvalidLengthError, InvalidRatingError, InvalidSourceError, TooManyColumnsError
Instance Method Summary collapse
-
#handle(line:) ⇒ Object
Handles this error based on config settings, and augments the error message with styling and the line from the file.
Instance Method Details
#handle(line:) ⇒ Object
Handles this error based on config settings, and augments the error message with styling and the line from the file. All this is handled here so that the parser doesn’t have to know all these things at the error’s point of origin.
13 14 15 16 17 18 19 |
# File 'lib/reading/errors.rb', line 13 def handle(line:) errors_config = line.csv.config.fetch(:errors) styled_error = styled_with_line(line.string, errors_config) handle = errors_config.fetch(:handle_error) handle.call(styled_error) end |