mirror of
https://github.com/node-red/node-red.git
synced 2023-10-10 13:36:53 +02:00
Errors in subflows propagate up to nearest catch node
This commit is contained in:
parent
00c612485b
commit
cbdd4de630
@ -68,17 +68,23 @@ function createSubflow(sf,sfn,subflows) {
|
|||||||
node.z = sfn.id;
|
node.z = sfn.id;
|
||||||
newNodes.push(node);
|
newNodes.push(node);
|
||||||
}
|
}
|
||||||
|
// Look for any catch nodes and update their scope ids
|
||||||
// Update all subflow interior wiring to reflect new node IDs
|
// Update all subflow interior wiring to reflect new node IDs
|
||||||
for (i=0;i<newNodes.length;i++) {
|
for (i=0;i<newNodes.length;i++) {
|
||||||
node = newNodes[i];
|
node = newNodes[i];
|
||||||
var outputs = node.wires;
|
var outputs = node.wires;
|
||||||
|
|
||||||
for (j=0;j<outputs.length;j++) {
|
for (j=0;j<outputs.length;j++) {
|
||||||
wires = outputs[j];
|
wires = outputs[j];
|
||||||
for (k=0;k<wires.length;k++) {
|
for (k=0;k<wires.length;k++) {
|
||||||
outputs[j][k] = node_map[outputs[j][k]].id
|
outputs[j][k] = node_map[outputs[j][k]].id
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (node.type === 'catch' && node.scope) {
|
||||||
|
node.scope = node.scope.map(function(id) {
|
||||||
|
return node_map[id]?node_map[id].id:""
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create a subflow node to accept inbound messages and route appropriately
|
// Create a subflow node to accept inbound messages and route appropriately
|
||||||
@ -226,31 +232,6 @@ function createCatchNodeMap(nodes) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (id in nodes) {
|
|
||||||
if (nodes.hasOwnProperty(id)) {
|
|
||||||
var m = /^subflow:(.+)$/.exec(nodes[id].type);
|
|
||||||
if (m) {
|
|
||||||
subflowInstances[id] = nodes[id];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for (id in subflowInstances) {
|
|
||||||
if (subflowInstances.hasOwnProperty(id)) {
|
|
||||||
var z = id;
|
|
||||||
while(subflowInstances[z]) {
|
|
||||||
var sfi = subflowInstances[z];
|
|
||||||
if (!catchNodes[z]) {
|
|
||||||
z = sfi.z;
|
|
||||||
} else {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (catchNodes[z]) {
|
|
||||||
catchNodes[id] = catchNodes[id]||[];
|
|
||||||
catchNodes[id].push(catchNodes[z]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return catchNodes;
|
return catchNodes;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -325,6 +306,7 @@ Flow.prototype.parseConfig = function(config) {
|
|||||||
} else {
|
} else {
|
||||||
this.nodes[nodeConfig.id] = nodeInfo;
|
this.nodes[nodeConfig.id] = nodeInfo;
|
||||||
}
|
}
|
||||||
|
if (nodeConfig.type != "catch") {
|
||||||
for (var prop in nodeConfig) {
|
for (var prop in nodeConfig) {
|
||||||
if (nodeConfig.hasOwnProperty(prop) &&
|
if (nodeConfig.hasOwnProperty(prop) &&
|
||||||
prop != "type" &&
|
prop != "type" &&
|
||||||
@ -338,6 +320,7 @@ Flow.prototype.parseConfig = function(config) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//console.log("NODES");
|
//console.log("NODES");
|
||||||
//for (i in this.nodes) {
|
//for (i in this.nodes) {
|
||||||
@ -760,15 +743,12 @@ Flow.prototype.handleError = function(node,logMessage,msg) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var targetCatchNodes = null;
|
var targetCatchNodes = null;
|
||||||
if (this.catchNodeMap[node.z]) {
|
var throwingNode = node;
|
||||||
targetCatchNodes = this.catchNodeMap[node.z];
|
var handled = false;
|
||||||
} else if (this.activeNodes[node.z] && this.catchNodeMap[this.activeNodes[node.z].z]) {
|
while (throwingNode && !handled) {
|
||||||
targetCatchNodes = this.catchNodeMap[this.activeNodes[node.z].z];
|
targetCatchNodes = this.catchNodeMap[throwingNode.z];
|
||||||
}
|
|
||||||
|
|
||||||
if (targetCatchNodes) {
|
if (targetCatchNodes) {
|
||||||
targetCatchNodes.forEach(function(targetCatchNode) {
|
targetCatchNodes.forEach(function(targetCatchNode) {
|
||||||
console.log(targetCatchNode.scope);
|
|
||||||
if (targetCatchNode.scope && targetCatchNode.scope.indexOf(node.id) === -1) {
|
if (targetCatchNode.scope && targetCatchNode.scope.indexOf(node.id) === -1) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -790,7 +770,12 @@ Flow.prototype.handleError = function(node,logMessage,msg) {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
targetCatchNode.receive(errorMessage);
|
targetCatchNode.receive(errorMessage);
|
||||||
})
|
handled = true;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
if (!handled) {
|
||||||
|
throwingNode = this.activeNodes[throwingNode.z];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user