return error message on console error

This commit is contained in:
Jonathan Rainville 2018-10-12 12:07:38 -04:00 committed by Pascal Precht
parent 939642f74c
commit e6964c75cb
No known key found for this signature in database
GPG Key ID: 0EE28D8D6FD85D7D
2 changed files with 5 additions and 1 deletions

View File

@ -14,6 +14,7 @@ class RunCode {
return vm.runInNewContext(code, this.context);
} catch(e) {
this.logger.error(e.message);
return e.message;
}
}

View File

@ -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});
}