mirror of
https://github.com/node-red/node-red
synced 2024-11-22 16:33:24 +00:00
Catches bad objects being encoded, returning instead the error.
Symptom- Observed that global context would not display in front end, the call returning 400. Traced to an object in global which cause encodeObject to except. This push catches that, and now global will display, but the object in question display as an error.
This commit is contained in:
parent
6f91786f4d
commit
bc283aa025
15
packages/node_modules/@node-red/util/lib/util.js
vendored
15
packages/node_modules/@node-red/util/lib/util.js
vendored
@ -652,6 +652,7 @@ function normaliseNodeTypeName(name) {
|
||||
* @memberof @node-red/util_util
|
||||
*/
|
||||
function encodeObject(msg,opts) {
|
||||
try {
|
||||
var debuglength = 1000;
|
||||
if (opts && opts.hasOwnProperty('maxLength')) {
|
||||
debuglength = opts.maxLength;
|
||||
@ -776,6 +777,20 @@ function encodeObject(msg,opts) {
|
||||
}
|
||||
}
|
||||
return msg;
|
||||
} catch(e) {
|
||||
msg.format = "error";
|
||||
var errorMsg = {};
|
||||
if (e.name) {
|
||||
errorMsg.name = e.name;
|
||||
}
|
||||
if (e.hasOwnProperty('message')) {
|
||||
errorMsg.message = e.message;
|
||||
} else {
|
||||
errorMsg.message = e.toString();
|
||||
}
|
||||
msg.msg = JSON.stringify(errorMsg);
|
||||
return msg;
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
|
Loading…
Reference in New Issue
Block a user