Class: Connectors::TolerableErrorHelper

Inherits:
Object
  • Object
show all
Defined in:
lib/connectors/tolerable_error_helper.rb

Instance Method Summary collapse

Constructor Details

#initialize(error_monitor) ⇒ TolerableErrorHelper

Returns a new instance of TolerableErrorHelper.



13
14
15
# File 'lib/connectors/tolerable_error_helper.rb', line 13

def initialize(error_monitor)
  @error_monitor = error_monitor
end

Instance Method Details

#yield_single_document(identifier: nil) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/connectors/tolerable_error_helper.rb', line 17

def yield_single_document(identifier: nil)
  Utility::Logger.debug("Extracting single document for #{identifier}") if identifier
  yield
  @error_monitor.note_success
rescue *fatal_exception_classes => e
  Utility::ExceptionTracking.augment_exception(e)
  Utility::Logger.error("Encountered a fall-through error during extraction#{identifying_error_message(identifier)}: #{e.class}: #{e.message} {:message_id => #{e.id}}")
  raise
rescue StandardError => e
  Utility::ExceptionTracking.augment_exception(e)
  Utility::Logger.warn("Encountered error during extraction#{identifying_error_message(identifier)}: #{e.class}: #{e.message} {:message_id => #{e.id}}")
  @error_monitor.note_error(e, :id => e.id)
end