Class: Synchronisable::ErrorHandler Private
- Inherits:
-
Object
- Object
- Synchronisable::ErrorHandler
- 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.
-
#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. Rescued exceptions are written to log and saved to errors array.
21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/synchronisable/error_handler.rb', line 21 def handle(source) block = ->() { yield return true } source.parent ? block.() : ActiveRecord::Base.transaction(&block) rescue Exception => e @context.errors << e log(e, source) return false end |