Add async property handling to Switch node

This commit is contained in:
Nick O'Leary
2018-07-09 11:30:53 +01:00
parent 9c00492dc2
commit fc9cdb61f2
3 changed files with 149 additions and 109 deletions

View File

@@ -350,7 +350,16 @@ function evaluateNodeProperty(value, type, node, msg, callback) {
var data = JSON.parse(value);
result = Buffer.from(data);
} else if (type === 'msg' && msg) {
result = getMessageProperty(msg,value);
try {
result = getMessageProperty(msg,value);
} catch(err) {
if (callback) {
callback(err);
} else {
throw err;
}
return;
}
} else if ((type === 'flow' || type === 'global') && node) {
var contextKey = parseContextStore(value);
result = node.context()[type].get(contextKey.key,contextKey.store,callback);
@@ -366,7 +375,7 @@ function evaluateNodeProperty(value, type, node, msg, callback) {
result = evaluteEnvProperty(value);
}
if (callback) {
callback(result);
callback(null,result);
} else {
return result;
}