mirror of https://github.com/embarklabs/embark.git
fix/improve error handling
This commit is contained in:
parent
750eace6ce
commit
aad78cc130
|
@ -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);
|
||||
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);
|
||||
|
|
|
@ -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<output.errors; i++) {
|
||||
for (let i=0; i<output.errors.length; i++) {
|
||||
if (output.errors[i].indexOf('Warning:') >= 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) {
|
||||
|
|
Loading…
Reference in New Issue