From 00dd8ecf91433b0a0bedfea6534ffde1809d8613 Mon Sep 17 00:00:00 2001 From: Iuri Matias Date: Sat, 29 Oct 2016 11:08:10 -0400 Subject: [PATCH] display compilation and/or deployment error in the logs and status instead of crashing --- lib/index.js | 34 ++++++++++++++++++++++++++-------- 1 file changed, 26 insertions(+), 8 deletions(-) diff --git a/lib/index.js b/lib/index.js index 1062eb69..74c7150f 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); }); },