Fix up function stack issues

This commit is contained in:
Nick O'Leary 2018-05-08 10:47:20 +01:00
parent 27bf72372e
commit 2efa78d590
No known key found for this signature in database
GPG Key ID: 4F2157149161A6C9
1 changed files with 3 additions and 3 deletions

View File

@ -205,7 +205,7 @@ module.exports = function(RED) {
var context = vm.createContext(sandbox); var context = vm.createContext(sandbox);
try { try {
this.script = vm.createScript(functionText, { this.script = vm.createScript(functionText, {
filename: 'Function Node:'+this.id+(this.name?' ['+this.name+']':'', // filename for stack traces filename: 'Function: '+this.id+(this.name?' ['+this.name+']':''), // filename for stack traces
lineOffset: -11, // line number offset to be used 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 columnOffset: 0, // column number offset to be used for stack traces
displayErrors: true displayErrors: true
@ -225,9 +225,9 @@ module.exports = function(RED) {
} }
} catch(err) { } catch(err) {
//remove unwanted part //remove unwanted part
const index = err.stack.search(/\n\s*at ContextifyScript.Script.runInContext/); var index = err.stack.search(/\n\s*at ContextifyScript.Script.runInContext/);
err.stack = err.stack.slice(0, index).split('\n').slice(0,-1).join('\n'); err.stack = err.stack.slice(0, index).split('\n').slice(0,-1).join('\n');
const stack = err.stack.split(/\r?\n/); var stack = err.stack.split(/\r?\n/);
//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;