1
0
mirror of https://github.com/node-red/node-red.git synced 2023-10-10 13:36:53 +02:00

Do not log node errors if handled by a Catch node

This commit is contained in:
Nick O'Leary 2017-05-03 13:42:38 +01:00
parent ed1a55d9cd
commit 8f92a3e875
No known key found for this signature in database
GPG Key ID: 4F2157149161A6C9
3 changed files with 16 additions and 9 deletions

View File

@ -243,10 +243,12 @@ Node.prototype.error = function(logMessage,msg) {
if (typeof logMessage != 'boolean') {
logMessage = logMessage || "";
}
log_helper(this, Log.ERROR, logMessage);
/* istanbul ignore else */
var handled = false;
if (msg) {
flows.handleError(this,logMessage,msg);
handled = flows.handleError(this,logMessage,msg);
}
if (!handled) {
log_helper(this, Log.ERROR, logMessage);
}
};

View File

@ -221,7 +221,7 @@ function Flow(global,flow) {
count = msg.error.source.count+1;
if (count === 10) {
node.warn(Log._("nodes.flow.error-loop"));
return;
return false;
}
}
}
@ -265,6 +265,7 @@ function Flow(global,flow) {
throwingNode = activeNodes[throwingNode.z];
}
}
return handled;
}
}

View File

@ -174,27 +174,31 @@ function getFlows() {
}
function delegateError(node,logMessage,msg) {
var handled = false;
if (activeFlows[node.z]) {
activeFlows[node.z].handleError(node,logMessage,msg);
handled = activeFlows[node.z].handleError(node,logMessage,msg);
} else if (activeNodesToFlow[node.z] && activeFlows[activeNodesToFlow[node.z]]) {
activeFlows[activeNodesToFlow[node.z]].handleError(node,logMessage,msg);
handled = activeFlows[activeNodesToFlow[node.z]].handleError(node,logMessage,msg);
} else if (activeFlowConfig.subflows[node.z] && subflowInstanceNodeMap[node.id]) {
subflowInstanceNodeMap[node.id].forEach(function(n) {
delegateError(getNode(n),logMessage,msg);
handled = handled || delegateError(getNode(n),logMessage,msg);
});
}
return handled;
}
function handleError(node,logMessage,msg) {
var handled = false;
if (node.z) {
delegateError(node,logMessage,msg);
handled = delegateError(node,logMessage,msg);
} else {
if (activeFlowConfig.configs[node.id]) {
activeFlowConfig.configs[node.id]._users.forEach(function(id) {
var userNode = activeFlowConfig.allNodes[id];
delegateError(userNode,logMessage,msg);
handled = handled || delegateError(userNode,logMessage,msg);
})
}
}
return handled;
}
function delegateStatus(node,statusMessage) {