diff --git a/lib/index.js b/lib/index.js index 1062eb698..74c7150ff 100644 --- a/lib/index.js +++ b/lib/index.js @@ -55,7 +55,6 @@ var Embark = { }, self.buildDeployGenerate.bind(self) ], function(err, result) { - Embark.monitor.setStatus("Ready"); self.logger.trace("finished".underline); }); }, @@ -108,7 +107,7 @@ var Embark = { callback(); } ], function(err, result) { - Embark.monitor.setStatus("Ready"); + Embark.monitor.setStatus("Ready".green); self.logger.trace("finished".underline); }); }, @@ -144,8 +143,12 @@ var Embark = { contractsConfig: self.config.contractsConfig, logger: Embark.logger }); - contractsManager.build(); - callback(null, contractsManager); + try { + contractsManager.build(); + callback(null, contractsManager); + } catch(err) { + callback(new Error(err.message)); + } }, function deployContracts(contractsManager, callback) { @@ -179,7 +182,11 @@ var Embark = { } ], function(err, result) { - done(result); + if (err) { + done(err, null); + } else { + done(null, result); + } }); }, @@ -204,11 +211,15 @@ var Embark = { buildDeployGenerate: function(done) { var self = this; + Embark.monitor.setStatus("Deploying...".magenta.underline); async.waterfall([ function deployAndBuildContractsManager(callback) { - Embark.monitor.setStatus("Deploying Contracts"); - Embark.buildAndDeploy(function(contractsManager) { - callback(null, contractsManager); + Embark.buildAndDeploy(function(err, contractsManager) { + if (err) { + callback(err); + } else { + callback(null, contractsManager); + } }); }, function generateConsoleABI(contractsManager, callback) { @@ -233,6 +244,13 @@ var Embark = { callback(); } ], function(err, result) { + if (err) { + self.logger.error("error deploying"); + self.logger.error(err.message); + Embark.monitor.setStatus("Deployment Error".red); + } else { + Embark.monitor.setStatus("Ready".green); + } done(result); }); },