From 945fbbc0659e0fc078f3b3ce1af73faf180b7c2e Mon Sep 17 00:00:00 2001 From: Nick O'Leary Date: Sun, 12 Jun 2016 11:07:05 +0100 Subject: [PATCH] Capture error stack on node.error Closes #879 --- red/runtime/log.js | 6 +++++- red/runtime/nodes/flows/Flow.js | 3 +++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/red/runtime/log.js b/red/runtime/log.js index 84eb2166f..21a32c005 100644 --- a/red/runtime/log.js +++ b/red/runtime/log.js @@ -72,7 +72,11 @@ var consoleLogger = function(msg) { if (msg.level == log.METRIC || msg.level == log.AUDIT) { util.log("["+levelNames[msg.level]+"] "+JSON.stringify(msg)); } else { - util.log("["+levelNames[msg.level]+"] "+(msg.type?"["+msg.type+":"+(msg.name||msg.id)+"] ":"")+msg.msg); + var message = msg.msg; + if (typeof message === 'object' && message.toString() === '[object Object]' && message.message) { + message = message.message; + } + util.log("["+levelNames[msg.level]+"] "+(msg.type?"["+msg.type+":"+(msg.name||msg.id)+"] ":"")+message); } } diff --git a/red/runtime/nodes/flows/Flow.js b/red/runtime/nodes/flows/Flow.js index f213b21a8..8309e134d 100644 --- a/red/runtime/nodes/flows/Flow.js +++ b/red/runtime/nodes/flows/Flow.js @@ -247,6 +247,9 @@ function Flow(global,flow) { count: count } }; + if (logMessage.hasOwnProperty('stack')) { + errorMessage.error.stack = logMessage.stack; + } targetCatchNode.receive(errorMessage); handled = true; });