mirror of
https://github.com/node-red/node-red.git
synced 2025-03-01 10:36:34 +00:00
Add 'catch uncaught only' mode to Catch node
Closes #1747 This was inspired by a PR from @mauriciom75 but implemented in a different way due to some of the internal reworking done to Flow and Subflow in the dev branch
This commit is contained in:
@@ -212,6 +212,21 @@ class Flow {
|
||||
}
|
||||
}
|
||||
}
|
||||
this.catchNodes.sort(function(A,B) {
|
||||
if (A.scope && !B.scope) {
|
||||
return -1;
|
||||
} else if (!A.scope && B.scope) {
|
||||
return 1;
|
||||
} else if (A.scope && B.scope) {
|
||||
return 0;
|
||||
} else if (A.uncaught && !B.uncaught) {
|
||||
return 1;
|
||||
} else if (!A.uncaught && B.uncaught) {
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
});
|
||||
|
||||
if (activeCount > 0) {
|
||||
this.trace("------------------|--------------|-----------------");
|
||||
}
|
||||
@@ -419,10 +434,20 @@ class Flow {
|
||||
}
|
||||
handled = true;
|
||||
} else {
|
||||
var handledByUncaught = false;
|
||||
|
||||
this.catchNodes.forEach(function(targetCatchNode) {
|
||||
if (targetCatchNode.scope && targetCatchNode.scope.indexOf(reportingNode.id) === -1) {
|
||||
return;
|
||||
}
|
||||
if (!targetCatchNode.scope && targetCatchNode.uncaught && !handledByUncaught) {
|
||||
if (handled) {
|
||||
// This has been handled by a !uncaught catch node
|
||||
return;
|
||||
}
|
||||
// This is an uncaught error
|
||||
handledByUncaught = true;
|
||||
}
|
||||
var errorMessage;
|
||||
if (msg) {
|
||||
errorMessage = redUtil.cloneMessage(msg);
|
||||
|
Reference in New Issue
Block a user