Use trace logger for code runner error

This commit is contained in:
Anthony Laibe 2018-09-10 09:26:37 +01:00
parent 8c3ac34fac
commit b41bcbbe17
2 changed files with 4 additions and 3 deletions

View File

@ -8,7 +8,7 @@ class CodeRunner {
this.events = options.events;
this.ipc = options.ipc;
this.commands = [];
this.runCode = new RunCode();
this.runCode = new RunCode({logger: this.logger});
this.registerIpcEvents();
this.IpcClientListen();
this.registerEvents();

View File

@ -1,7 +1,8 @@
const vm = require('vm');
class RunCode {
constructor() {
constructor({logger}) {
this.logger = logger;
this.context = Object.assign({}, {global, console, exports, require, module, __filename, __dirname});
}
@ -9,7 +10,7 @@ class RunCode {
try {
return vm.runInNewContext(code, this.context);
} catch(e) {
console.error(e.message);
this.logger.trace(e.message);
}
}