Class: NatsWork::Middleware::ErrorHandler
- Inherits:
-
Object
- Object
- NatsWork::Middleware::ErrorHandler
- Defined in:
- lib/natswork/middleware.rb
Instance Method Summary collapse
- #call(job, message) ⇒ Object
-
#initialize(on_error: nil) ⇒ ErrorHandler
constructor
A new instance of ErrorHandler.
Constructor Details
#initialize(on_error: nil) ⇒ ErrorHandler
Returns a new instance of ErrorHandler.
100 101 102 |
# File 'lib/natswork/middleware.rb', line 100 def initialize(on_error: nil) @on_error = on_error end |
Instance Method Details
#call(job, message) ⇒ Object
104 105 106 107 108 109 110 111 112 113 114 115 |
# File 'lib/natswork/middleware.rb', line 104 def call(job, ) yield rescue StandardError => e ['error'] = { 'type' => e.class.name, 'message' => e. } @on_error&.call(job, , e) raise end |