From 9f7a93225260e6ee43f331027e90aedcee8795f0 Mon Sep 17 00:00:00 2001 From: Jonathan Rainville Date: Wed, 12 Sep 2018 11:55:29 -0400 Subject: [PATCH 1/2] don't stop on contract fail --- lib/modules/deployment/index.js | 41 +++++++++++++++++++-------------- 1 file changed, 24 insertions(+), 17 deletions(-) diff --git a/lib/modules/deployment/index.js b/lib/modules/deployment/index.js index 3ab3f127a..aa87ab3f2 100644 --- a/lib/modules/deployment/index.js +++ b/lib/modules/deployment/index.js @@ -52,6 +52,7 @@ class DeployManager { self.events.emit("deploy:beforeAll"); const contractDeploys = {}; + const errors = []; contracts.forEach(contract => { function deploy(result, callback) { if (typeof result === 'function') { @@ -59,7 +60,11 @@ class DeployManager { } contract._gasLimit = self.gasLimit; self.events.request('deploy:contract', contract, (err) => { - callback(err); + if (err) { + contract.error = err.message || err; + errors.push(err); + } + callback(); }); } @@ -72,23 +77,25 @@ class DeployManager { contractDeploys[className].push(deploy); }); - async.auto(contractDeploys, function(err, _results) { - if (err) { - self.logger.error(__("error deploying contracts")); - if(err.message !== undefined) { - self.logger.error(err.message); - self.logger.debug(err.stack); - } else { - self.logger.error(err); + try { + async.auto(contractDeploys, function(_err, _results) { + if (errors.length) { + self.logger.error(__("error deploying contracts")); + errors.forEach(error => { + self.logger.error(error.message || error); + }); } - } - if (contracts.length === 0) { - self.logger.info(__("no contracts found")); - return done(); - } - self.logger.info(__("finished deploying contracts")); - done(err); - }); + if (contracts.length === 0) { + self.logger.info(__("no contracts found")); + return done(); + } + self.logger.info(__("finished deploying contracts")); + done(err); + }); + } catch (e) { + self.logger.error(e.message || e); + done(__('Error deploying')); + } }); }); } From 4c912b8ecfb8868ba05ab64c4f17fe66f910fa44 Mon Sep 17 00:00:00 2001 From: Jonathan Rainville Date: Wed, 12 Sep 2018 12:04:33 -0400 Subject: [PATCH 2/2] stop on error --- lib/modules/deployment/index.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/modules/deployment/index.js b/lib/modules/deployment/index.js index aa87ab3f2..1ea9064f8 100644 --- a/lib/modules/deployment/index.js +++ b/lib/modules/deployment/index.js @@ -62,6 +62,7 @@ class DeployManager { self.events.request('deploy:contract', contract, (err) => { if (err) { contract.error = err.message || err; + self.logger.error(err.message || err); errors.push(err); } callback(); @@ -80,10 +81,9 @@ class DeployManager { try { async.auto(contractDeploys, function(_err, _results) { if (errors.length) { - self.logger.error(__("error deploying contracts")); - errors.forEach(error => { - self.logger.error(error.message || error); - }); + _err = __("Error deploying contracts. Please fix errors to continue."); + self.logger.error(_err); + return done(_err); } if (contracts.length === 0) { self.logger.info(__("no contracts found"));