Add better error checking for Robot#halt
This commit is contained in:
parent
754af3b4db
commit
d56f9bc53f
16
lib/robot.js
16
lib/robot.js
|
@ -394,12 +394,22 @@ Robot.prototype.startDevices = function(callback) {
|
|||
Robot.prototype.halt = function(callback) {
|
||||
callback = callback || function() {};
|
||||
|
||||
if (!this.isRunning) {
|
||||
return callback();
|
||||
}
|
||||
|
||||
var devices = _.map(this.devices, "halt");
|
||||
var connections = _.map(this.connections, "disconnect");
|
||||
|
||||
Async.parallel(devices, function() {
|
||||
Async.parallel(connections, callback);
|
||||
});
|
||||
try {
|
||||
Async.parallel(devices, function() {
|
||||
Async.parallel(connections, callback);
|
||||
});
|
||||
} catch (e) {
|
||||
var msg = "An error occured while attempting to safely halt the robot";
|
||||
this.log("error", msg);
|
||||
this.log("error", e.message);
|
||||
}
|
||||
|
||||
this.running = false;
|
||||
};
|
||||
|
|
|
@ -550,6 +550,8 @@ describe("Robot", function() {
|
|||
}
|
||||
});
|
||||
|
||||
bot.isRunning = true;
|
||||
|
||||
device = bot.devices.ping;
|
||||
connection = bot.connections.loopback;
|
||||
|
||||
|
|
Loading…
Reference in New Issue