Merge pull request #820 from embark-framework/bug_fix/error-deploy-pending

Don't stop everything on contract deploy fail
This commit is contained in:
Iuri Matias 2018-09-12 18:50:56 -04:00 committed by GitHub
commit edd9ece585
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 24 additions and 17 deletions

View File

@ -52,6 +52,7 @@ class DeployManager {
self.events.emit("deploy:beforeAll"); self.events.emit("deploy:beforeAll");
const contractDeploys = {}; const contractDeploys = {};
const errors = [];
contracts.forEach(contract => { contracts.forEach(contract => {
function deploy(result, callback) { function deploy(result, callback) {
if (typeof result === 'function') { if (typeof result === 'function') {
@ -59,7 +60,12 @@ class DeployManager {
} }
contract._gasLimit = self.gasLimit; contract._gasLimit = self.gasLimit;
self.events.request('deploy:contract', contract, (err) => { self.events.request('deploy:contract', contract, (err) => {
callback(err); if (err) {
contract.error = err.message || err;
self.logger.error(err.message || err);
errors.push(err);
}
callback();
}); });
} }
@ -72,23 +78,24 @@ class DeployManager {
contractDeploys[className].push(deploy); contractDeploys[className].push(deploy);
}); });
async.auto(contractDeploys, function(err, _results) { try {
if (err) { async.auto(contractDeploys, function(_err, _results) {
self.logger.error(__("error deploying contracts")); if (errors.length) {
if(err.message !== undefined) { _err = __("Error deploying contracts. Please fix errors to continue.");
self.logger.error(err.message); self.logger.error(_err);
self.logger.debug(err.stack); return done(_err);
} else {
self.logger.error(err);
} }
} if (contracts.length === 0) {
if (contracts.length === 0) { self.logger.info(__("no contracts found"));
self.logger.info(__("no contracts found")); return done();
return done(); }
} self.logger.info(__("finished deploying contracts"));
self.logger.info(__("finished deploying contracts")); done(err);
done(err); });
}); } catch (e) {
self.logger.error(e.message || e);
done(__('Error deploying'));
}
}); });
}); });
} }