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

Add try/catch to WOL node to try to grab socket error.

(Upstream fix requested).
This commit is contained in:
Dave C-J 2014-11-19 20:36:04 +00:00
parent 0a15d2d539
commit 661a50b123
2 changed files with 9 additions and 4 deletions

View File

@ -28,9 +28,14 @@ module.exports = function(RED) {
var mac = this.mac || msg.mac || null; var mac = this.mac || msg.mac || null;
if (mac != null) { if (mac != null) {
if (chk.test(mac)) { if (chk.test(mac)) {
try {
wol.wake(mac, function(error) { wol.wake(mac, function(error) {
if (error) { node.warn(error); } if (error) { node.warn(error); }
else if (RED.settings.verbose) {
node.log("sent WOL magic packet");
}
}); });
} catch(e) { if (RED.settings.verbose) { node.log("WOL: socket error"); }
} }
else { node.warn('WOL: bad mac address "'+mac+'"'); } else { node.warn('WOL: bad mac address "'+mac+'"'); }
} }

View File

@ -3,7 +3,7 @@
"version" : "0.0.2", "version" : "0.0.2",
"description" : "A Node-RED node to send Wake-On-LAN (WOL) magic packets", "description" : "A Node-RED node to send Wake-On-LAN (WOL) magic packets",
"dependencies" : { "dependencies" : {
"wake_on_lan" : "0.0.3" "wake_on_lan" : "0.0.4"
}, },
"repository" : { "repository" : {
"type":"git", "type":"git",