Class: Qs::ErrorHandler
- Inherits:
-
Object
- Object
- Qs::ErrorHandler
- Defined in:
- lib/qs/error_handler.rb
Constant Summary collapse
- STANDARD_ERROR_CLASSES =
these are standard error classes that we rescue and run through any configured error procs; use the same standard error classes that dat-worker-pool rescues
DatWorkerPool::Worker::STANDARD_ERROR_CLASSES
Instance Attribute Summary collapse
-
#context ⇒ Object
readonly
Returns the value of attribute context.
-
#error_procs ⇒ Object
readonly
Returns the value of attribute error_procs.
-
#exception ⇒ Object
readonly
Returns the value of attribute exception.
Instance Method Summary collapse
-
#initialize(exception, context_hash) ⇒ ErrorHandler
constructor
A new instance of ErrorHandler.
-
#run ⇒ Object
The exception that we are handling can change in the case that the configured error proc raises an exception.
Constructor Details
#initialize(exception, context_hash) ⇒ ErrorHandler
Returns a new instance of ErrorHandler.
15 16 17 18 19 |
# File 'lib/qs/error_handler.rb', line 15 def initialize(exception, context_hash) @exception = exception @context = ErrorContext.new(context_hash) @error_procs = context_hash[:daemon_data].error_procs.reverse end |
Instance Attribute Details
#context ⇒ Object (readonly)
Returns the value of attribute context.
13 14 15 |
# File 'lib/qs/error_handler.rb', line 13 def context @context end |
#error_procs ⇒ Object (readonly)
Returns the value of attribute error_procs.
13 14 15 |
# File 'lib/qs/error_handler.rb', line 13 def error_procs @error_procs end |
#exception ⇒ Object (readonly)
Returns the value of attribute exception.
13 14 15 |
# File 'lib/qs/error_handler.rb', line 13 def exception @exception end |
Instance Method Details
#run ⇒ Object
The exception that we are handling can change in the case that the configured error proc raises an exception. If this occurs, the new exception will be passed to subsequent error procs. This is designed to avoid “hidden” errors, this way the daemon will log based on the last exception that occurred.
26 27 28 29 30 31 32 33 34 |
# File 'lib/qs/error_handler.rb', line 26 def run @error_procs.each do |error_proc| begin error_proc.call(@exception, @context) rescue *STANDARD_ERROR_CLASSES => proc_exception @exception = proc_exception end end end |