mirror of
https://github.com/node-red/node-red.git
synced 2025-03-01 10:36:34 +00:00
Pass full error object in Function node and copy over cause property
Fixes #4683
This commit is contained in:
parent
08927dfb55
commit
66a667fe58
@ -438,10 +438,9 @@ module.exports = function(RED) {
|
|||||||
|
|
||||||
//store the error in msg to be used in flows
|
//store the error in msg to be used in flows
|
||||||
msg.error = err;
|
msg.error = err;
|
||||||
|
|
||||||
var line = 0;
|
|
||||||
var errorMessage;
|
|
||||||
if (stack.length > 0) {
|
if (stack.length > 0) {
|
||||||
|
let line = 0;
|
||||||
|
let errorMessage;
|
||||||
while (line < stack.length && stack[line].indexOf("ReferenceError") !== 0) {
|
while (line < stack.length && stack[line].indexOf("ReferenceError") !== 0) {
|
||||||
line++;
|
line++;
|
||||||
}
|
}
|
||||||
@ -455,11 +454,13 @@ module.exports = function(RED) {
|
|||||||
errorMessage += " (line "+lineno+", col "+cha+")";
|
errorMessage += " (line "+lineno+", col "+cha+")";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (errorMessage) {
|
||||||
|
err.message = errorMessage
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (!errorMessage) {
|
// Pass the whole error object so any additional properties
|
||||||
errorMessage = err.toString();
|
// (such as cause) are preserved
|
||||||
}
|
done(err);
|
||||||
done(errorMessage);
|
|
||||||
}
|
}
|
||||||
else if (typeof err === "string") {
|
else if (typeof err === "string") {
|
||||||
done(err);
|
done(err);
|
||||||
|
@ -678,6 +678,9 @@ class Flow {
|
|||||||
if (logMessage.hasOwnProperty('stack')) {
|
if (logMessage.hasOwnProperty('stack')) {
|
||||||
errorMessage.error.stack = logMessage.stack;
|
errorMessage.error.stack = logMessage.stack;
|
||||||
}
|
}
|
||||||
|
if (logMessage.hasOwnProperty('cause')) {
|
||||||
|
errorMessage.error.cause = logMessage.cause;
|
||||||
|
}
|
||||||
targetCatchNode.receive(errorMessage);
|
targetCatchNode.receive(errorMessage);
|
||||||
handled = true;
|
handled = true;
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user