display compilation and/or deployment error in the logs and status instead of crashing

This commit is contained in:
Iuri Matias 2016-10-29 11:08:10 -04:00
parent 816e67370a
commit 00dd8ecf91
1 changed files with 26 additions and 8 deletions

View File

@ -55,7 +55,6 @@ var Embark = {
}, },
self.buildDeployGenerate.bind(self) self.buildDeployGenerate.bind(self)
], function(err, result) { ], function(err, result) {
Embark.monitor.setStatus("Ready");
self.logger.trace("finished".underline); self.logger.trace("finished".underline);
}); });
}, },
@ -108,7 +107,7 @@ var Embark = {
callback(); callback();
} }
], function(err, result) { ], function(err, result) {
Embark.monitor.setStatus("Ready"); Embark.monitor.setStatus("Ready".green);
self.logger.trace("finished".underline); self.logger.trace("finished".underline);
}); });
}, },
@ -144,8 +143,12 @@ var Embark = {
contractsConfig: self.config.contractsConfig, contractsConfig: self.config.contractsConfig,
logger: Embark.logger logger: Embark.logger
}); });
contractsManager.build(); try {
callback(null, contractsManager); contractsManager.build();
callback(null, contractsManager);
} catch(err) {
callback(new Error(err.message));
}
}, },
function deployContracts(contractsManager, callback) { function deployContracts(contractsManager, callback) {
@ -179,7 +182,11 @@ var Embark = {
} }
], function(err, result) { ], function(err, result) {
done(result); if (err) {
done(err, null);
} else {
done(null, result);
}
}); });
}, },
@ -204,11 +211,15 @@ var Embark = {
buildDeployGenerate: function(done) { buildDeployGenerate: function(done) {
var self = this; var self = this;
Embark.monitor.setStatus("Deploying...".magenta.underline);
async.waterfall([ async.waterfall([
function deployAndBuildContractsManager(callback) { function deployAndBuildContractsManager(callback) {
Embark.monitor.setStatus("Deploying Contracts"); Embark.buildAndDeploy(function(err, contractsManager) {
Embark.buildAndDeploy(function(contractsManager) { if (err) {
callback(null, contractsManager); callback(err);
} else {
callback(null, contractsManager);
}
}); });
}, },
function generateConsoleABI(contractsManager, callback) { function generateConsoleABI(contractsManager, callback) {
@ -233,6 +244,13 @@ var Embark = {
callback(); callback();
} }
], function(err, result) { ], 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); done(result);
}); });
}, },