From e6964c75cb7a1563b792f2ddce82df59f8a15416 Mon Sep 17 00:00:00 2001 From: Jonathan Rainville Date: Fri, 12 Oct 2018 12:07:38 -0400 Subject: [PATCH] return error message on console error --- lib/core/modules/coderunner/runCode.js | 1 + lib/modules/console/index.js | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-) 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}); }