Class: Ruote::Exp::OnErrorExpression
- Inherits:
-
FlowExpression
- Object
- FlowExpression
- Ruote::Exp::OnErrorExpression
- Defined in:
- lib/ruote/exp/fe_on_error.rb
Overview
Up until ruote 2.3.0, ‘on_error’ was only an attribute
sequence :on_error => 'error_handler' do
# ...
end
This ‘on_error’ expression makes such definitions possible
sequence do
on_error /unknown participant/ => 'missing_participant'
on_error 'decommission'
# ...
end
where errors containing ‘unknown participant’ in their messages are handled by the participant or subprocess named ‘missing participant’, while the rest of the errors is handled by the participant or the subprocess named ‘decommission’.
Speaking of subprocesses, this is also possible
sequence do
on_error /unknown participant/ do
admin :msg => 'there was an unknown participant'
end
on_error do
# decommissioning...
end
# ...
end
Constant Summary
Constants inherited from FlowExpression
FlowExpression::COMMON_ATT_KEYS
Instance Attribute Summary
Attributes inherited from FlowExpression
Instance Method Summary collapse
Methods inherited from FlowExpression
#ancestor?, #applied_workitem, #att, #att_text, #attribute, #attribute_text, #attributes, #cancel, #cancel_flanks, #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, #iterative_var_lookup, #launch_sub, #lookup_val, #lookup_val_prefix, #lookup_variable, #name, names, #parent, #parent_id, #persist_or_raise, #reply_to_parent, #root, #root_id, #set_variable, #to_h, #tree, #tree_children, #try_persist, #try_unpersist, #unpersist_or_raise, #unset_variable, #update_tree, #variables, #wfid
Methods included from WithMeta
Methods included from WithH
Constructor Details
This class inherits a constructor from Ruote::Exp::FlowExpression
Instance Method Details
#apply ⇒ Object
66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 |
# File 'lib/ruote/exp/fe_on_error.rb', line 66 def apply regex = nil handler = attribute_text if handler == '' regex = (attributes.keys - COMMON_ATT_KEYS).first handler = attribute(regex) end if tree.last.size > 0 regex = handler handler = [ 'sequence', {}, Ruote.fulldup(tree.last) ] end return reply_to_parent(h.applied_workitem) if regex.nil? && handler.nil? # nothing to register, let's move on par = parent oe = par.h.on_error if oe.is_a?(String) or Ruote.is_tree?(oe) oe = [ nil, oe ] end oe = Array(par.h.on_error).compact oe << [ regex, handler, fei.child_id ] par.h.on_error = oe if par.do_persist reply_to_parent(h.applied_workitem) # success else apply # try again end end |
#reply(workitem) ⇒ Object
103 104 105 106 |
# File 'lib/ruote/exp/fe_on_error.rb', line 103 def reply(workitem) # never called end |