diff --git a/embark-ui/src/actions/index.js b/embark-ui/src/actions/index.js index e04ad458..ed933356 100644 --- a/embark-ui/src/actions/index.js +++ b/embark-ui/src/actions/index.js @@ -222,6 +222,7 @@ export const fiddleProfile = { timestamp = lastFiddle.timestamp; compilationResult = lastFiddle.compilationResult; } + if(fiddleProfile === '') fiddleProfile = undefined; return action(FIDDLE_PROFILE[SUCCESS], {fiddleProfiles: [{fiddleProfile, timestamp, compilationResult}]}); }, failure: (error) => action(FIDDLE_PROFILE[FAILURE], {error}) diff --git a/embark-ui/src/containers/FiddleContainer.js b/embark-ui/src/containers/FiddleContainer.js index 2d03e02c..b2ce8feb 100644 --- a/embark-ui/src/containers/FiddleContainer.js +++ b/embark-ui/src/containers/FiddleContainer.js @@ -223,7 +223,7 @@ class FiddleContainer extends Component { fatalFiddleDeployCard={this._renderFatalCard("Failed to deploy", fiddleDeployError)} compiledContractsCard={compiledFiddle && compiledFiddle.compilationResult && this._renderSuccessCard("Contract(s) compiled!", profiledFiddle && )} diff --git a/lib/modules/solidity/index.js b/lib/modules/solidity/index.js index 72c42efa..9ab3df9e 100644 --- a/lib/modules/solidity/index.js +++ b/lib/modules/solidity/index.js @@ -28,14 +28,16 @@ class Solidity { return res.status(422).send({error: 'Body parameter \'codeToCompile\' must be a string'}); } const input = {'fiddle': {content: sourceCode.replace(/\r\n/g, '\n')}}; - this.compile_solidity_code(input, {}, true, (errors, compilationResult) => { + this.compile_solidity_code(input, {}, true, (error, compilationResult, errors) => { + if (error) res.status(500).send({error: error.message}); + // write code to filesystem so we can view the source after page refresh const className = !compilationResult ? 'temp' : Object.keys(compilationResult).join('_'); this._writeFiddleToFile(sourceCode, className, Boolean(compilationResult), (err) => { if (err) this.logger.trace('Error writing fiddle to filesystem: ', err); }); // async, do not need to wait - const responseData = {errors: errors, compilationResult: compilationResult}; + const responseData = {errors, compilationResult}; this.logger.trace(`POST response /embark-api/contract/compile:\n ${JSON.stringify(responseData)}`); res.send(responseData); }); @@ -71,16 +73,13 @@ class Solidity { if (err) { return callback(err); } - if (output.errors && returnAllErrors) { - return callback(output.errors); - } if (output.errors) { for (let i = 0; i < output.errors.length; i++) { if (output.errors[i].type === 'Warning') { self.logger.warn(output.errors[i].formattedMessage); } - if (output.errors[i].type === 'Error' || output.errors[i].severity === 'error') { + if ((output.errors[i].type === 'Error' || output.errors[i].severity === 'error') && !returnAllErrors) { return callback(new Error("Solidity errors: " + output.errors[i].formattedMessage).message); } } @@ -175,9 +174,12 @@ class Solidity { } } - callback(null, compiled_object); + callback(null, compiled_object, output.errors); + } + ], function (err, result, errors) { + if (returnAllErrors) { + return cb(err, result, errors); } - ], function (err, result) { cb(err, result); }); }