Class: Cascade::ErrorHandler
- Inherits:
-
Object
- Object
- Cascade::ErrorHandler
- Extended by:
- Configuration
- Defined in:
- lib/cascade/error_handler.rb
Constant Summary collapse
- HANDLING_EXCEPTIONS =
[IndexError]
- 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.
Methods included from Configuration
Constructor Details
#initialize(options = {}) ⇒ ErrorHandler
Returns a new instance of ErrorHandler.
15 16 17 18 19 20 |
# File 'lib/cascade/error_handler.rb', line 15 def initialize( = {}) @error_store = .fetch(:error_store) { DEFAULT_ERROR_STORE } @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
26 27 28 29 30 31 |
# File 'lib/cascade/error_handler.rb', line 26 def with_errors_handling(row) yield rescue *@handling_exceptions => exception @error_store.call(row, exception) raise exception if self.class.raise_parse_errors end |