Class: Cascade::ErrorHandler
- Inherits:
-
Object
- Object
- Cascade::ErrorHandler
- Defined in:
- lib/cascade/error_handler.rb
Constant Summary collapse
- HANDLING_EXCEPTIONS =
[IndexError].freeze
- DEFAULT_ERROR_STORE =
lambda do |row, exception| @errors ||= [] @errors << [row, exception.to_s] end
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ ErrorHandler
constructor
A new instance of ErrorHandler.
-
#with_errors_handling(row) ⇒ Object
Runs passed block with catching throwing errors and storing in ErrorStore.
Constructor Details
#initialize(options = {}) ⇒ ErrorHandler
Returns a new instance of ErrorHandler.
11 12 13 14 15 16 17 |
# File 'lib/cascade/error_handler.rb', line 11 def initialize( = {}) @error_store = .fetch(:error_store) { DEFAULT_ERROR_STORE } @raise_parse_errors = .fetch(:raise_parse_errors, false) @handling_exceptions = .fetch(:handling_exceptions) do HANDLING_EXCEPTIONS end end |
Instance Method Details
#with_errors_handling(row) ⇒ Object
Runs passed block with catching throwing errors and storing in ErrorStore
problems with processing
23 24 25 26 27 28 |
# File 'lib/cascade/error_handler.rb', line 23 def with_errors_handling(row) yield rescue *@handling_exceptions => exception @error_store.call(row, exception) raise exception if @raise_parse_errors end |