fix(compiler): display errors that before were not showing

This commit is contained in:
Jonathan Rainville 2018-11-09 11:49:32 -05:00
parent be406860d3
commit 9052c64249
1 changed files with 24 additions and 4 deletions

View File

@ -105,12 +105,32 @@ function compileSolc(embark, contractFiles, cb) {
if (err) {
return callback(err);
}
let json;
try {
json = JSON.parse(compileString);
} catch (e) {
logger.error(e.message || e);
return callback(`Compiling ${file} returned an unreadable result`);
}
const contracts = json.contracts;
let json = JSON.parse(compileString).contracts;
if (json.errors) {
let isError = false;
json.errors.forEach(error => {
if (error.severity === 'error') {
isError = true;
logger.error(error.formattedMessage);
}
for (let contractFile in json) {
for (let contractName in json[contractFile]) {
let contract = json[contractFile][contractName];
});
if (isError) {
return callback(`Error while compiling ${file}`);
}
}
for (let contractFile in contracts) {
for (let contractName in contracts[contractFile]) {
let contract = contracts[contractFile][contractName];
const className = contractName;
const filename = contractFile;