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.

re (since ruote 2.3.1)

The re or reraise attribute can be used to bring back an error placed in a workitem field or a process variable and raise it again.

Ruote.define do

  define 'handler' do
    set 'f:err' => '$f:__error__'
  end
  sequence :on_error => 'handler' do
    error 'fail!'
  end

  # error was intercepted and is now stashed in
  # workitem field 'err'

  error :re => '$f:err'
end

Constant Summary

Constants inherited from FlowExpression

FlowExpression::COMMON_ATT_KEYS

Instance Attribute Summary

Attributes inherited from FlowExpression

#context, #error

Instance Method Summary collapse

Methods inherited from FlowExpression

#ancestor?, #applied_workitem, #att, #att_text, #attribute, #attribute_text, #attributes, #await, #cancel, #cancel_flanks, #cfei_at, #child_id, #child_ids, #compile_atts, #compile_variables, #debug_id, #deflate, #do, do_action, #do_apply, #do_cancel, #do_fail, #do_pause, #do_persist, #do_reply, #do_reply_to_parent, #do_resume, #do_unpersist, dummy, #fei, fetch, from_h, #handle_on_error, #has_attribute, #initial_persist, #initialize, #is_concurrent?, #iterative_var_lookup, #launch_sub, #lookup_val, #lookup_val_prefix, #lookup_variable, #name, names, #parent, #parent_id, #pause_on_apply, #persist_or_raise, #reply_to_parent, #root, #root_id, #set_variable, #tree, #tree_children, #try_persist, #try_unpersist, #unpersist_or_raise, #unset_variable, #update_tree, #variables, #wfid

Methods included from WithMeta

#class_def, included

Methods included from WithH

#h, #h=, included, #to_h

Constructor Details

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

Instance Method Details

#applyObject


77
78
79
80
81
82
83
84
85
86
# File 'lib/ruote/exp/fe_error.rb', line 77

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


88
89
90
91
92
93
94
95
96
97
# File 'lib/ruote/exp/fe_error.rb', line 88

def reply(workitem)

  return reply_to_parent(workitem) if h.triggered

  if has_attribute('re', 'reraise')
    re_raise
  else
    raise_new_error
  end
end