mirror of https://github.com/embarklabs/embark.git
fix error display with refactored compilation module
This commit is contained in:
parent
d44a68f176
commit
c500bb4988
|
@ -19,6 +19,7 @@ var Compiler = function(options) {
|
||||||
};
|
};
|
||||||
|
|
||||||
Compiler.prototype.compile_contracts = function(contractFiles, cb) {
|
Compiler.prototype.compile_contracts = function(contractFiles, cb) {
|
||||||
|
var self = this;
|
||||||
|
|
||||||
var available_compilers = {
|
var available_compilers = {
|
||||||
//".se": this.compile_serpent
|
//".se": this.compile_serpent
|
||||||
|
@ -45,13 +46,13 @@ Compiler.prototype.compile_contracts = function(contractFiles, cb) {
|
||||||
return (file.filename.match(/\.[0-9a-z]+$/)[0] === extension);
|
return (file.filename.match(/\.[0-9a-z]+$/)[0] === extension);
|
||||||
});
|
});
|
||||||
|
|
||||||
compiler.call(compiler, matchingFiles || [], function(compileResult) {
|
compiler.call(compiler, matchingFiles || [], function(err, compileResult) {
|
||||||
Object.assign(compiledObject, compileResult);
|
Object.assign(compiledObject, compileResult);
|
||||||
callback();
|
callback(err, compileResult);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
function (err) {
|
function (err) {
|
||||||
cb(compiledObject);
|
cb(err, compiledObject);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
@ -84,10 +85,9 @@ Compiler.prototype.compile_solidity = function(contractFiles, cb) {
|
||||||
function compileContracts(callback) {
|
function compileContracts(callback) {
|
||||||
self.logger.info("compiling contracts...");
|
self.logger.info("compiling contracts...");
|
||||||
solcW.compile({sources: input}, 1, function(output) {
|
solcW.compile({sources: input}, 1, function(output) {
|
||||||
// TODO: check error is handled properly
|
if (output.errors) {
|
||||||
//if (output.errors) {
|
return callback(new Error ("Solidity errors: " + output.errors).message);
|
||||||
// throw new Error ("Solidity errors: " + output.errors);
|
}
|
||||||
//}
|
|
||||||
callback(null, output);
|
callback(null, output);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
@ -109,7 +109,7 @@ Compiler.prototype.compile_solidity = function(contractFiles, cb) {
|
||||||
callback(null, compiled_object);
|
callback(null, compiled_object);
|
||||||
}
|
}
|
||||||
], function(err, result) {
|
], function(err, result) {
|
||||||
cb(result);
|
cb(err, result);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -40,15 +40,10 @@ ContractsManager.prototype.build = function(done) {
|
||||||
async.waterfall([
|
async.waterfall([
|
||||||
function compileContracts(callback) {
|
function compileContracts(callback) {
|
||||||
var compiler = new Compiler({plugins: self.plugins, logger: self.logger});
|
var compiler = new Compiler({plugins: self.plugins, logger: self.logger});
|
||||||
// TODO: check if try is still needed
|
compiler.compile_contracts(self.contractFiles, function(err, compiledObject) {
|
||||||
//try {
|
|
||||||
compiler.compile_contracts(self.contractFiles, function(compiledObject) {
|
|
||||||
self.compiledContracts = compiledObject;
|
self.compiledContracts = compiledObject;
|
||||||
callback();
|
callback(err);
|
||||||
});
|
});
|
||||||
//} catch(err) {
|
|
||||||
// return callback(new Error(err.message));
|
|
||||||
//}
|
|
||||||
},
|
},
|
||||||
function prepareContractsFromConfig(callback) {
|
function prepareContractsFromConfig(callback) {
|
||||||
var className, contract;
|
var className, contract;
|
||||||
|
@ -169,13 +164,11 @@ ContractsManager.prototype.build = function(done) {
|
||||||
callback();
|
callback();
|
||||||
}
|
}
|
||||||
], function(err, result) {
|
], function(err, result) {
|
||||||
self.logger.trace("finished".underline);
|
|
||||||
if (err) {
|
if (err) {
|
||||||
//self.logger.debug(err.stack);
|
self.logger.error("Error Compiling/Building contracts: " + err);
|
||||||
done(err);
|
|
||||||
} else {
|
|
||||||
done(null, self);
|
|
||||||
}
|
}
|
||||||
|
self.logger.trace("finished".underline);
|
||||||
|
done(err, self);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue