diff --git a/lib/contracts/deploy_manager.js b/lib/contracts/deploy_manager.js index 3f9990c6b..b59673381 100644 --- a/lib/contracts/deploy_manager.js +++ b/lib/contracts/deploy_manager.js @@ -117,9 +117,17 @@ class DeployManager { return callback(new Error("error running afterDeploy")); } + // TODO: convert to for to avoid repeated callback onDeployCode.forEach((cmd) => { self.logger.info("executing: " + cmd); - RunCode.doEval(cmd, web3); + try { + RunCode.doEval(cmd, web3); + } catch(e) { + if (e.message.indexOf("invalid opcode") >= 0) { + self.logger.error('the transaction was rejected; this usually happens due to a throw or a require, it can also happen due to an invalid operation'); + } + return callback(new Error(e)); + } }); callback(null, contractsManager); diff --git a/lib/modules/solidity/index.js b/lib/modules/solidity/index.js index 2087268bd..0270214ae 100644 --- a/lib/modules/solidity/index.js +++ b/lib/modules/solidity/index.js @@ -51,8 +51,11 @@ class Solidity { self.logger.info("compiling contracts..."); solcW.compile({sources: input}, 1, function (output) { if (output.errors) { - for (let i=0; i= 0) { + //return callback(new Error("Solidity errors: " + output.errors).message); + } + if (output.errors[i].indexOf('Error:') >= 0) { return callback(new Error("Solidity errors: " + output.errors).message); } } @@ -64,6 +67,10 @@ class Solidity { function createCompiledObject(output, callback) { let json = output.contracts; + if (Object.keys(output.contracts).length === 0 && output.sourceList.length > 0) { + return callback(new Error("error compiling. There are sources available but no code could be compiled, likely due to fatal errors in the solidity code").message); + } + let compiled_object = {}; for (let contractName in json) {