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

better script error handling.

Also pass the error in msg so that it can handled later
This commit is contained in:
Martin Guillon 2018-04-17 10:52:53 +02:00 committed by GitHub
parent 27fdc9e56e
commit 20f03c356c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -204,7 +204,12 @@ module.exports = function(RED) {
}
var context = vm.createContext(sandbox);
try {
this.script = vm.createScript(functionText);
this.script = vm.createScript(functionText, {
filename: this.name + '_' + this.id, // filename for stack traces
lineOffset: -11, // line number offset to be used for stack traces
columnOffset: 0, // column number offset to be used for stack traces
displayErrors: true
});
this.on("input", function(msg) {
try {
var start = process.hrtime();
@ -219,7 +224,7 @@ module.exports = function(RED) {
this.status({fill:"yellow",shape:"dot",text:""+converted});
}
} catch(err) {
msg.error = err;
var line = 0;
var errorMessage;
var stack = err.stack.split(/\r?\n/);