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:
parent
612dd4dc7f
commit
3b60e1a0e3
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user