diff --git a/lib/robot.js b/lib/robot.js index b672e4a..f41bbed 100644 --- a/lib/robot.js +++ b/lib/robot.js @@ -295,11 +295,15 @@ Robot.prototype.start = function(callback) { Logger.fatal("An error occured while trying to start the robot:"); Logger.fatal(err); - if (typeof(this.error) === "function") { - this.error.call(this, err); - } + this.halt(function() { + if (typeof(this.error) === "function") { + this.error.call(this, err); + } - this.emit("error", err); + if (this.listeners("error").length) { + this.emit("error", err); + } + }.bind(this)); } if (_.isFunction(callback)) {