Class: Qs::ErrorHandler
- Inherits:
-
Object
- Object
- Qs::ErrorHandler
- Defined in:
- lib/qs/error_handler.rb
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.
9 10 11 12 13 |
# File 'lib/qs/error_handler.rb', line 9 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.
7 8 9 |
# File 'lib/qs/error_handler.rb', line 7 def context @context end |
#error_procs ⇒ Object (readonly)
Returns the value of attribute error_procs.
7 8 9 |
# File 'lib/qs/error_handler.rb', line 7 def error_procs @error_procs end |
#exception ⇒ Object (readonly)
Returns the value of attribute exception.
7 8 9 |
# File 'lib/qs/error_handler.rb', line 7 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.
20 21 22 23 24 25 26 27 28 |
# File 'lib/qs/error_handler.rb', line 20 def run @error_procs.each do |error_proc| begin error_proc.call(@exception, @context) rescue StandardError => proc_exception @exception = proc_exception end end end |