Class: Ruote::ErrorHandler

Inherits:
Object
  • Object
show all
Defined in:
lib/ruote/svc/error_handler.rb

Overview

A ruote service for turning exceptions 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).

Instance Method Summary collapse

Constructor Details

#initialize(context) ⇒ ErrorHandler

Returns a new instance of ErrorHandler.



38
39
40
41
# File 'lib/ruote/svc/error_handler.rb', line 38

def initialize(context)

  @context = context
end

Instance Method Details

#action_handle(action, fei, exception) ⇒ Object

As used by some receivers (see ruote-beanstalk’s receiver).



56
57
58
59
60
61
62
63
64
65
66
67
# File 'lib/ruote/svc/error_handler.rb', line 56

def action_handle(action, fei, exception)

  fexp = Ruote::Exp::FlowExpression.fetch(@context, fei)

  msg = {
    'action' => action,
    'fei' => fei,
    'participant_name' => fexp.h.participant_name,
    'workitem' => fexp.h.applied_workitem }

  handle(msg, fexp, exception)
end

#msg_handle(msg, exception) ⇒ Object

As used by the dispatch pool and the worker.



45
46
47
48
49
50
51
52
# File 'lib/ruote/svc/error_handler.rb', line 45

def msg_handle(msg, exception)

  fexp = Ruote::Exp::FlowExpression.fetch(
    @context, msg['fei'] || msg['workitem']['fei']
  ) rescue nil

  handle(msg, fexp, exception)
end