mirror of
https://github.com/node-red/node-red-nodes.git
synced 2025-03-01 10:37:43 +00:00
Add more error handling and reporting
This commit is contained in:
parent
d5343c6b02
commit
5e819fdfcd
@ -503,9 +503,13 @@ module.exports = function(RED) {
|
|||||||
'sid': req.headers.sid
|
'sid': req.headers.sid
|
||||||
};
|
};
|
||||||
//console.log("Incoming Event %s", req.body.toString());
|
//console.log("Incoming Event %s", req.body.toString());
|
||||||
wemo.parseEvent(req.body.toString()).then(function(evt) {
|
wemo.parseEvent(req.body.toString())
|
||||||
|
.then(function(evt) {
|
||||||
evt.sid = notification.sid;
|
evt.sid = notification.sid;
|
||||||
wemo.emit('event',evt);
|
wemo.emit('event',evt);
|
||||||
|
})
|
||||||
|
.catch(err => {
|
||||||
|
console.log(err)
|
||||||
});
|
});
|
||||||
res.send('');
|
res.send('');
|
||||||
});
|
});
|
||||||
|
@ -413,7 +413,7 @@ WeMoNG.prototype.getSocketStatus = function getSocketStatus(socket) {
|
|||||||
status = parseInt(status);
|
status = parseInt(status);
|
||||||
def.resolve(status);
|
def.resolve(status);
|
||||||
} else {
|
} else {
|
||||||
def.reject();
|
def.reject(err);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -422,12 +422,12 @@ WeMoNG.prototype.getSocketStatus = function getSocketStatus(socket) {
|
|||||||
post_request.on('error', function (e) {
|
post_request.on('error', function (e) {
|
||||||
console.log(e);
|
console.log(e);
|
||||||
console.log("%j", postoptions);
|
console.log("%j", postoptions);
|
||||||
def.reject();
|
def.reject(e);
|
||||||
});
|
});
|
||||||
|
|
||||||
post_request.on('timeout', function(){
|
post_request.on('timeout', function(){
|
||||||
post_request.abort();
|
post_request.abort();
|
||||||
def.reject();
|
def.reject("timeout");
|
||||||
});
|
});
|
||||||
|
|
||||||
post_request.write(getSocketState.body);
|
post_request.write(getSocketState.body);
|
||||||
@ -473,12 +473,12 @@ WeMoNG.prototype.getInsightParams = function getInsightParams(socket) {
|
|||||||
post_request.on('error', function (e) {
|
post_request.on('error', function (e) {
|
||||||
console.log(e);
|
console.log(e);
|
||||||
console.log("%j", postoptions);
|
console.log("%j", postoptions);
|
||||||
def.reject();
|
def.reject(e);
|
||||||
});
|
});
|
||||||
|
|
||||||
post_request.on('timeout', function(){
|
post_request.on('timeout', function(){
|
||||||
post_request.abort();
|
post_request.abort();
|
||||||
def.reject();
|
def.reject("timeout");
|
||||||
});
|
});
|
||||||
|
|
||||||
post_request.write(getInsightParameters.body);
|
post_request.write(getInsightParameters.body);
|
||||||
@ -526,14 +526,14 @@ WeMoNG.prototype.getLightStatus = function getLightStatus(light) {
|
|||||||
};
|
};
|
||||||
def.resolve(obj);
|
def.resolve(obj);
|
||||||
} else {
|
} else {
|
||||||
def.reject();
|
def.reject(err);
|
||||||
console.log("err");
|
console.log("err");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
console.log("err");
|
console.log("err");
|
||||||
def.reject();
|
def.reject(err);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -542,12 +542,12 @@ WeMoNG.prototype.getLightStatus = function getLightStatus(light) {
|
|||||||
post_request.on('error', function (e) {
|
post_request.on('error', function (e) {
|
||||||
console.log(e);
|
console.log(e);
|
||||||
console.log("%j", postoptions);
|
console.log("%j", postoptions);
|
||||||
def.reject();
|
def.reject(e);
|
||||||
});
|
});
|
||||||
|
|
||||||
post_request.on('timeout', function () {
|
post_request.on('timeout', function () {
|
||||||
console.log("Timeout");
|
console.log("Timeout");
|
||||||
post_request.abort();
|
post_request.abort("timeout");
|
||||||
def.reject();
|
def.reject();
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -617,7 +617,7 @@ WeMoNG.prototype.parseEvent = function parseEvent(evt) {
|
|||||||
msg.value = res['StateEvent']['Value'][0];
|
msg.value = res['StateEvent']['Value'][0];
|
||||||
def.resolve(msg);
|
def.resolve(msg);
|
||||||
} else {
|
} else {
|
||||||
def.reject();
|
def.reject(err);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else if (prop.hasOwnProperty('BinaryState')) {
|
} else if (prop.hasOwnProperty('BinaryState')) {
|
||||||
@ -634,7 +634,7 @@ WeMoNG.prototype.parseEvent = function parseEvent(evt) {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
//error
|
//error
|
||||||
def.reject();
|
def.reject(err);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user