Class: Synchronisable::ErrorHandler Private
- Defined in:
- lib/synchronisable/error_handler.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Helper class for synchronization errors handling.
Instance Method Summary collapse
-
#handle(source) ⇒ Boolean
private
Wraps the given block in transaction if it’s source for a model on which #sync method was called and not a parent/child association.
-
#initialize(logger, context) ⇒ ErrorHandler
constructor
private
A new instance of ErrorHandler.
Constructor Details
#initialize(logger, context) ⇒ ErrorHandler
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of ErrorHandler.
10 11 12 |
# File 'lib/synchronisable/error_handler.rb', line 10 def initialize(logger, context) @logger, @context = logger, context end |
Instance Method Details
#handle(source) ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Wraps the given block in transaction if it’s source for a model on which #sync method was called and not a parent/child association. Rescued exceptions are written to log and saved to the errors array.
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/synchronisable/error_handler.rb', line 22 def handle(source) invoke(source) do yield return true end rescue SystemExit, Interrupt raise rescue Exception => e err_msg = (e, source) @context.errors << err_msg @logger.error err_msg return false end |