mirror of
https://github.com/node-red/node-red.git
synced 2023-10-10 13:36:53 +02:00
Fix jsonata err reporting in sort node
This commit is contained in:
parent
9bf87697fd
commit
49da324c5d
@ -926,8 +926,8 @@
|
|||||||
"ascending" : "ascending",
|
"ascending" : "ascending",
|
||||||
"descending" : "descending",
|
"descending" : "descending",
|
||||||
"as-number" : "as number",
|
"as-number" : "as number",
|
||||||
"invalid-exp" : "invalid JSONata expression in sort node",
|
"invalid-exp" : "Invalid JSONata expression in sort node: __message__",
|
||||||
"too-many" : "too many pending messages in sort node",
|
"too-many" : "Too many pending messages in sort node",
|
||||||
"clear" : "clear pending message in sort node"
|
"clear" : "clear pending message in sort node"
|
||||||
},
|
},
|
||||||
"batch" : {
|
"batch" : {
|
||||||
|
@ -61,7 +61,7 @@ module.exports = function(RED) {
|
|||||||
key_exp = RED.util.prepareJSONataExpression(key_exp, this);
|
key_exp = RED.util.prepareJSONataExpression(key_exp, this);
|
||||||
}
|
}
|
||||||
catch (e) {
|
catch (e) {
|
||||||
node.error(RED._("sort.invalid-exp"));
|
node.error(RED._("sort.invalid-exp",{message:e.toString()}));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -86,10 +86,14 @@ module.exports = function(RED) {
|
|||||||
var evaluatedDataPromises = msgs.map(msg => {
|
var evaluatedDataPromises = msgs.map(msg => {
|
||||||
return new Promise((resolve,reject) => {
|
return new Promise((resolve,reject) => {
|
||||||
RED.util.evaluateJSONataExpression(key_exp, msg, (err, result) => {
|
RED.util.evaluateJSONataExpression(key_exp, msg, (err, result) => {
|
||||||
|
if (err) {
|
||||||
|
reject(RED._("sort.invalid-exp",{message:err.toString()}));
|
||||||
|
} else {
|
||||||
resolve({
|
resolve({
|
||||||
item: msg,
|
item: msg,
|
||||||
sortValue: result
|
sortValue: result
|
||||||
})
|
})
|
||||||
|
}
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
@ -130,10 +134,14 @@ module.exports = function(RED) {
|
|||||||
var evaluatedDataPromises = data.map(elem => {
|
var evaluatedDataPromises = data.map(elem => {
|
||||||
return new Promise((resolve,reject) => {
|
return new Promise((resolve,reject) => {
|
||||||
RED.util.evaluateJSONataExpression(key_exp, elem, (err, result) => {
|
RED.util.evaluateJSONataExpression(key_exp, elem, (err, result) => {
|
||||||
|
if (err) {
|
||||||
|
reject(RED._("sort.invalid-exp",{message:err.toString()}));
|
||||||
|
} else {
|
||||||
resolve({
|
resolve({
|
||||||
item: elem,
|
item: elem,
|
||||||
sortValue: result
|
sortValue: result
|
||||||
})
|
})
|
||||||
|
}
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
@ -186,6 +194,7 @@ module.exports = function(RED) {
|
|||||||
node.send(msg);
|
node.send(msg);
|
||||||
}
|
}
|
||||||
}).catch(err => {
|
}).catch(err => {
|
||||||
|
node.error(err,msg);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
var parts = msg.parts;
|
var parts = msg.parts;
|
||||||
@ -209,7 +218,9 @@ module.exports = function(RED) {
|
|||||||
pending_count++;
|
pending_count++;
|
||||||
if (group.count === msgs.length) {
|
if (group.count === msgs.length) {
|
||||||
delete pending[gid]
|
delete pending[gid]
|
||||||
sortMessageGroup(group);
|
sortMessageGroup(group).catch(err => {
|
||||||
|
node.error(err,msg);
|
||||||
|
});
|
||||||
pending_count -= msgs.length;
|
pending_count -= msgs.length;
|
||||||
} else {
|
} else {
|
||||||
var max_msgs = max_kept_msgs_count(node);
|
var max_msgs = max_kept_msgs_count(node);
|
||||||
|
Loading…
Reference in New Issue
Block a user