diff --git a/lib/core/modules/coderunner/runCode.js b/lib/core/modules/coderunner/runCode.js index 2e6dab3d4..2ec3cdaa2 100644 --- a/lib/core/modules/coderunner/runCode.js +++ b/lib/core/modules/coderunner/runCode.js @@ -14,6 +14,7 @@ class RunCode { return vm.runInNewContext(code, this.context); } catch(e) { this.logger.error(e.message); + return e.message; } } diff --git a/lib/modules/console/index.js b/lib/modules/console/index.js index 00fef4b27..9c97f22cd 100644 --- a/lib/modules/console/index.js +++ b/lib/modules/console/index.js @@ -31,7 +31,10 @@ class Console { registerApi() { let plugin = this.plugins.createPlugin('consoleApi', {}); plugin.registerAPICall('post', '/embark-api/command', (req, res) => { - this.executeCmd(req.body.command, (_err, result) => { + this.executeCmd(req.body.command, (err, result) => { + if (err) { + return res.send({result: err.message || err}); + } if (typeof result === 'string') { return res.send({result}); }