From a386c028b056b864d7bc0a9d82b447c985cfcff7 Mon Sep 17 00:00:00 2001 From: Nick O'Leary Date: Wed, 16 Apr 2014 11:37:18 +0100 Subject: [PATCH] Handle null debug messages Fixes #200 --- nodes/core/core/58-debug.js | 11 +++++++---- nodes/core/core/80-function.js | 4 ++-- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/nodes/core/core/58-debug.js b/nodes/core/core/58-debug.js index 8d4704df7..1c77a047c 100644 --- a/nodes/core/core/58-debug.js +++ b/nodes/core/core/58-debug.js @@ -62,8 +62,7 @@ RED.nodes.registerType("debug",DebugNode); DebugNode.send = function(msg) { if (msg.msg instanceof Error) { msg.msg = msg.msg.toString(); - } - else if (typeof msg.msg === 'object') { + } else if (typeof msg.msg === 'object') { var seen = []; var ty = "(Object) "; if (util.isArray(msg.msg)) { ty = "(Array) "; } @@ -75,9 +74,13 @@ DebugNode.send = function(msg) { return value; }," "); seen = null; + } else if (typeof msg.msg === "boolean") { + msg.msg = "(boolean) "+msg.msg.toString(); + } else if (msg.msg === 0) { + msg.msg = "0"; + } else if (msg.msg == null) { + msg.msg = "[undefined]"; } - else if (typeof msg.msg === "boolean") msg.msg = "(boolean) "+msg.msg.toString(); - else if (msg.msg === 0) msg.msg = "0"; if (msg.msg.length > debuglength) { msg.msg = msg.msg.substr(0,debuglength) +" ...."; diff --git a/nodes/core/core/80-function.js b/nodes/core/core/80-function.js index c02af92fa..683eecd69 100644 --- a/nodes/core/core/80-function.js +++ b/nodes/core/core/80-function.js @@ -58,12 +58,12 @@ function FunctionNode(n) { this.send(results); } catch(err) { - this.error(err.message); + this.error(err); } } }); } catch(err) { - this.error(err.message); + this.error(err); } }