mirror of
https://github.com/node-red/node-red.git
synced 2025-03-01 10:36:34 +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:
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 = {
|
||||
|
Reference in New Issue
Block a user