From 5967f4b0d44d3b973a8a8c9d335c083381ff0d03 Mon Sep 17 00:00:00 2001 From: Martin Guillon Date: Tue, 17 Apr 2018 15:46:09 +0200 Subject: [PATCH] fix error stack --- nodes/core/core/80-function.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/nodes/core/core/80-function.js b/nodes/core/core/80-function.js index 7f0c2627b..2d5f7901a 100644 --- a/nodes/core/core/80-function.js +++ b/nodes/core/core/80-function.js @@ -224,7 +224,15 @@ module.exports = function(RED) { this.status({fill:"yellow",shape:"dot",text:""+converted}); } } catch(err) { + //remove unwanted part + const index = err.stack.search(/\n\s*at ContextifyScript.Script.runInContext/); + err.stack = err.stack.slice(0, index).split('\n').slice(0,-1).join('\n'); + console.log(index, err.stack); + const stack = err.stack.split(/\r?\n/); + + //store the error in msg to be used in flows msg.error = err; + var line = 0; var errorMessage; var stack = err.stack.split(/\r?\n/);