mirror of
https://github.com/node-red/node-red.git
synced 2025-03-01 10:36:34 +00:00
update handling of invalid jsonata expression
This commit is contained in:
@@ -45,6 +45,19 @@ module.exports = function(RED) {
|
||||
this.cronjob = null;
|
||||
var node = this;
|
||||
|
||||
node.props.forEach(function (prop) {
|
||||
if (prop.vt === "jsonata") {
|
||||
try {
|
||||
var val = prop.v ? prop.v : "";
|
||||
prop.exp = RED.util.prepareJSONataExpression(val, node);
|
||||
}
|
||||
catch (err) {
|
||||
node.error(RED._("inject.errors.invalid-expr", {error:err.message}));
|
||||
prop.exp = null;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
if (node.repeat > 2147483) {
|
||||
node.error(RED._("inject.errors.toolong", this));
|
||||
delete node.repeat;
|
||||
@@ -86,10 +99,22 @@ module.exports = function(RED) {
|
||||
|
||||
if (!property) return;
|
||||
|
||||
if (valueType === "jsonata") {
|
||||
if (p.exp) {
|
||||
try {
|
||||
var val = RED.util.evaluateJSONataExpression(p.exp, msg);
|
||||
RED.util.setMessageProperty(msg, property, val, true);
|
||||
}
|
||||
catch (err) {
|
||||
errors.push(err.message);
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
try {
|
||||
RED.util.setMessageProperty(msg,property,RED.util.evaluateNodeProperty(value, valueType, this, msg),true);
|
||||
} catch (err) {
|
||||
errors.push(err);
|
||||
errors.push(err.toString());
|
||||
}
|
||||
});
|
||||
|
||||
|
@@ -83,7 +83,8 @@
|
||||
"success": "Successfully injected: __label__",
|
||||
"errors": {
|
||||
"failed": "inject failed, see log for details",
|
||||
"toolong": "Interval too large"
|
||||
"toolong": "Interval too large",
|
||||
"invalid-expr": "Invalid JSONata expression: __error__"
|
||||
}
|
||||
},
|
||||
"catch": {
|
||||
|
@@ -83,7 +83,8 @@
|
||||
"success": "inject処理を実行しました: __label__",
|
||||
"errors": {
|
||||
"failed": "inject処理が失敗しました。詳細はログを確認してください。",
|
||||
"toolong": "時間間隔が大き過ぎます"
|
||||
"toolong": "時間間隔が大き過ぎます",
|
||||
"invalid-expr": "JSONata式が不正: __error__"
|
||||
}
|
||||
},
|
||||
"catch": {
|
||||
|
Reference in New Issue
Block a user