1
0
mirror of https://github.com/node-red/node-red.git synced 2023-10-10 13:36:53 +02:00

Added error trap to xml2js node.

This commit is contained in:
Dave C-J 2013-10-22 20:25:14 +01:00
parent 612dd4dc7f
commit 3b60e1a0e3
2 changed files with 48 additions and 47 deletions

View File

@ -22,24 +22,25 @@ try {
var eyes = require("eyes");
gotEyes = true;
} catch(e) {
util.log("[73-parsexml.js] Warning: Module 'eyes' not installed");
util.log("[73-parsexml.js] Note: Module 'eyes' not installed. (not needed, but useful)");
}
function Xml2jsNode(n) {
RED.nodes.createNode(this,n);
this.useEyes = n.useEyes;
var node = this;
this.on("input", function(msg) {
parseString(msg.payload, function (err, result) {
if (err) { node.error(err; }
else {
msg.payload = result;
node.send(msg);
if (node.useEyes == true) {
if (gotEyes == true) { eyes.inspect(msg); }
else { node.log(JSON.stringify(msg)); }
}
}
});
});
}
RED.nodes.registerType("xml2js",Xml2jsNode);