Ensure status/error events are propagated to parent properly

This commit is contained in:
Nick O'Leary
2019-01-25 13:35:02 +00:00
parent 3c8e4f8bbf
commit c99b35428b
3 changed files with 153 additions and 27 deletions

View File

@@ -191,6 +191,50 @@ class Subflow extends Flow {
}
super.start(diff);
}
/**
* Handle a status event from a node within this flow.
* @param {Node} node The original node that triggered the event
* @param {Object} statusMessage The status object
* @param {Node} reportingNode The node emitting the status event.
* This could be a subflow instance node when the status
* is being delegated up.
* @param {boolean} muteStatus Whether to emit the status event
* @return {[type]} [description]
*/
handleStatus(node,statusMessage,reportingNode,muteStatus) {
let handled = super.handleStatus(node,statusMessage,reportingNode,muteStatus);
if (!handled) {
// No status node on this subflow caught the status message.
// Pass up to the parent with this subflow's instance as the
// reporting node
handled = this.parent.handleStatus(node,statusMessage,this.node,true);
}
return handled;
}
/**
* Handle an error event from a node within this flow. If there are no Catch
* nodes within this flow, pass the event to the parent flow.
* @param {[type]} node [description]
* @param {[type]} logMessage [description]
* @param {[type]} msg [description]
* @param {[type]} reportingNode [description]
* @return {[type]} [description]
*/
handleError(node,logMessage,msg,reportingNode) {
let handled = super.handleError(node,logMessage,msg,reportingNode);
if (!handled) {
// No catch node on this subflow caught the error message.
// Pass up to the parent with the subflow's instance as the
// reporting node.
handled = this.parent.handleError(node,logMessage,msg,this.node);
}
return handled;
}
}