Skip to content

Commit a79e4d1

Browse files
committed
Node logged errors not displayed properly in debug pane
Fixes node-red#1116
1 parent f462435 commit a79e4d1

2 files changed

Lines changed: 14 additions & 2 deletions

File tree

nodes/core/core/58-debug.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,16 @@ module.exports = function(RED) {
7979
function sendDebug(msg) {
8080
if (msg.msg instanceof Error) {
8181
msg.format = "error";
82-
msg.msg = msg.msg.toString();
82+
var errorMsg = {};
83+
if (msg.msg.name) {
84+
errorMsg.name = msg.msg.name;
85+
}
86+
if (msg.msg.hasOwnProperty('message')) {
87+
errorMsg.message = msg.msg.message;
88+
} else {
89+
errorMsg.message = msg.msg.toString();
90+
}
91+
msg.msg = JSON.stringify(errorMsg);
8392
} else if (msg.msg instanceof Buffer) {
8493
msg.format = "buffer["+msg.msg.length+"]";
8594
msg.msg = msg.msg.toString('hex');

nodes/core/core/lib/debug/debug-utils.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,8 +230,11 @@ RED.debug = (function() {
230230
(o.property?'msg.'+property:'msg')+" : "+format+
231231
'</span>').appendTo(metaRow);
232232
}
233-
if (format === 'Object' || /^array/.test(format) || format === 'boolean' || format === 'number'||/error/i.test(format) ) {
233+
if (format === 'Object' || /^array/.test(format) || format === 'boolean' || format === 'number' ) {
234234
payload = JSON.parse(payload);
235+
} else if (/error/i.test(format)) {
236+
payload = JSON.parse(payload);
237+
payload = (payload.name?payload.name+": ":"")+payload.message;
235238
} else if (format === 'null') {
236239
payload = null;
237240
} else if (format === 'undefined') {

0 commit comments

Comments
 (0)