Class: Ruote::ErrorHandler
- Inherits:
-
Object
- Object
- Ruote::ErrorHandler
- Defined in:
- lib/ruote/svc/error_handler.rb
Overview
A ruote service for turning errors into process errors (or letting those error fire any potential :on_error attributes in the process definition).
This service is used, by the worker, the dispatch pool and some receivers (like the one in ruote-beanstalk).
Defined Under Namespace
Classes: RaisedError
Instance Method Summary collapse
-
#action_handle(action, fei, err) ⇒ Object
As used by some receivers (see ruote-beanstalk’s receiver).
-
#initialize(context) ⇒ ErrorHandler
constructor
A new instance of ErrorHandler.
-
#msg_handle(msg, err) ⇒ Object
As used by the dispatch pool and the worker.
-
#msg_raise(msg, err) ⇒ Object
Packages the error in a ‘raise’ msg and places it in the storage, for a worker to pick it up.
Constructor Details
#initialize(context) ⇒ ErrorHandler
Returns a new instance of ErrorHandler.
52 53 54 55 |
# File 'lib/ruote/svc/error_handler.rb', line 52 def initialize(context) @context = context end |
Instance Method Details
#action_handle(action, fei, err) ⇒ Object
As used by some receivers (see ruote-beanstalk’s receiver).
TODO: at some point, merge that with #msg_raise
88 89 90 91 92 93 94 95 96 97 98 99 100 |
# File 'lib/ruote/svc/error_handler.rb', line 88 def action_handle(action, fei, err) fexp = Ruote::Exp::FlowExpression.fetch(@context, fei) msg = { 'action' => action, 'fei' => fei, 'participant_name' => fexp.h.participant_name, 'workitem' => fexp.h.applied_workitem, 'put_at' => Ruote.now_to_utc_s } handle(msg, fexp, err) end |
#msg_handle(msg, err) ⇒ Object
As used by the dispatch pool and the worker.
59 60 61 62 63 64 65 66 |
# File 'lib/ruote/svc/error_handler.rb', line 59 def msg_handle(msg, err) fexp = Ruote::Exp::FlowExpression.fetch( @context, msg['fei'] || msg['workitem']['fei'] ) rescue nil handle(msg, fexp, err) end |
#msg_raise(msg, err) ⇒ Object
Packages the error in a ‘raise’ msg and places it in the storage, for a worker to pick it up.
71 72 73 74 75 76 77 78 79 80 81 82 |
# File 'lib/ruote/svc/error_handler.rb', line 71 def msg_raise(msg, err) fei = msg['fei'] wfid = msg['wfid'] || msg.fetch('fei', {})['wfid'] @context.storage.put_msg( 'raise', 'fei' => fei, 'wfid' => wfid, 'msg' => msg, 'error' => deflate(err, fei)) end |