Add error handler for devices that fail to initialize.

Do not start work if devices fail to initialize and throw err insted.
This commit is contained in:
edgarsilva 2014-04-01 17:53:34 -06:00
parent 6d36709207
commit de360ba2b3
1 changed files with 9 additions and 5 deletions

View File

@ -188,11 +188,15 @@ namespace("Cylon", function() {
Robot.prototype.start = function() {
var self = this;
return this.startConnections(function() {
return self.robot.startDevices(function() {
self.robot.work.call(self.robot, self.robot);
self.running = true;
Logger.info("Working...");
return self.robot.emit('working');
return self.robot.startDevices(function(err) {
if (err) {
throw err;
}else{
self.robot.work.call(self.robot, self.robot);
self.running = true;
Logger.info("Working...");
self.robot.emit('working');
}
});
});
};