Class: Ruote::Exp::ErrorExpression

Inherits:
FlowExpression show all
Defined in:
lib/ruote/exp/fe_error.rb

Overview

Triggers an error directly from the process definition.

Ruote.process_definition :name => 'log1' do
  sequence do
    perform_inventory
    error 'inventory issue', :if => '${f:level} < 1'
    order_new_stuff
    store_new_stuff
  end
end

Replaying the error will ‘unlock’ the process.

Constant Summary

Constants inherited from FlowExpression

FlowExpression::COMMON_ATT_KEYS

Instance Attribute Summary

Attributes inherited from FlowExpression

#context, #error, #h

Instance Method Summary collapse

Methods inherited from FlowExpression

#ancestor?, #att, #attribute, #attribute_text, #attributes, #cancel, #compile_atts, #compile_variables, do_action, #do_apply, #do_cancel, #do_fail, #do_pause, #do_persist, #do_reply, #do_resume, #do_unpersist, #expand_atts, #fei, fetch, from_h, #handle_on_error, #has_attribute, #initial_persist, #initialize, #iterative_var_lookup, #launch_sub, #lookup_on_error, #lookup_val, #lookup_val_prefix, #lookup_variable, #name, names, #parent, #parent_id, #persist_or_raise, #reply_to_parent, #set_variable, #to_h, #tree, #tree_children, #try_persist, #try_unpersist, #unpersist_or_raise, #unset_variable, #update_tree, #variables

Methods included from WithMeta

#class_def, included

Methods included from WithH

included

Constructor Details

This class inherits a constructor from Ruote::Exp::FlowExpression

Instance Method Details

#applyObject



56
57
58
59
60
61
62
63
64
65
# File 'lib/ruote/exp/fe_error.rb', line 56

def apply

  # making the error occurs in the reply() phase
  # so that the replay_at_error targets the reply and not the apply

  @context.storage.put_msg(
    'reply',
    'fei' => h.fei,
    'workitem' => h.applied_workitem)
end

#reply(workitem) ⇒ Object

Raises:



67
68
69
70
71
72
73
74
75
76
77
78
79
# File 'lib/ruote/exp/fe_error.rb', line 67

def reply(workitem)

  return reply_to_parent(workitem) if h.triggered

  msg = attribute(:msg) || attribute(:message) || attribute_text
  msg = 'error triggered from process definition' if msg.strip == ''

  h.triggered = true

  persist_or_raise # to keep track of h.triggered

  raise(Ruote::ForcedError.new(msg))
end