1
0
mirror of https://github.com/node-red/node-red.git synced 2023-10-10 13:36:53 +02:00

Node logged errors not displayed properly in debug pane

Fixes #1116
This commit is contained in:
Nick O'Leary 2017-01-14 21:33:11 +00:00
parent f462435dc2
commit a79e4d1bb3
No known key found for this signature in database
GPG Key ID: 4F2157149161A6C9
2 changed files with 14 additions and 2 deletions

View File

@ -79,7 +79,16 @@ module.exports = function(RED) {
function sendDebug(msg) { function sendDebug(msg) {
if (msg.msg instanceof Error) { if (msg.msg instanceof Error) {
msg.format = "error"; msg.format = "error";
msg.msg = msg.msg.toString(); var errorMsg = {};
if (msg.msg.name) {
errorMsg.name = msg.msg.name;
}
if (msg.msg.hasOwnProperty('message')) {
errorMsg.message = msg.msg.message;
} else {
errorMsg.message = msg.msg.toString();
}
msg.msg = JSON.stringify(errorMsg);
} else if (msg.msg instanceof Buffer) { } else if (msg.msg instanceof Buffer) {
msg.format = "buffer["+msg.msg.length+"]"; msg.format = "buffer["+msg.msg.length+"]";
msg.msg = msg.msg.toString('hex'); msg.msg = msg.msg.toString('hex');

View File

@ -230,8 +230,11 @@ RED.debug = (function() {
(o.property?'msg.'+property:'msg')+" : "+format+ (o.property?'msg.'+property:'msg')+" : "+format+
'</span>').appendTo(metaRow); '</span>').appendTo(metaRow);
} }
if (format === 'Object' || /^array/.test(format) || format === 'boolean' || format === 'number'||/error/i.test(format) ) { if (format === 'Object' || /^array/.test(format) || format === 'boolean' || format === 'number' ) {
payload = JSON.parse(payload); payload = JSON.parse(payload);
} else if (/error/i.test(format)) {
payload = JSON.parse(payload);
payload = (payload.name?payload.name+": ":"")+payload.message;
} else if (format === 'null') { } else if (format === 'null') {
payload = null; payload = null;
} else if (format === 'undefined') { } else if (format === 'undefined') {