IPC works with errors, console print errors

This commit is contained in:
Anthony Laibe 2018-08-15 10:40:51 +01:00 committed by Iuri Matias
parent dd8658a59a
commit a59cc29d39
4 changed files with 12 additions and 15 deletions

View File

@ -62,7 +62,7 @@ class Console {
if (this.ipc.connected && this.ipc.isClient()) { if (this.ipc.connected && this.ipc.isClient()) {
return this.ipc.request('console:executeCmd', cmd, callback); return this.ipc.request('console:executeCmd', cmd, callback);
} }
callback(e.message); callback(e);
} }
} }
} }

View File

@ -368,10 +368,11 @@ class Monitor {
executeCmd(cmd, cb) { executeCmd(cmd, cb) {
const self = this; const self = this;
self.logText.log('console> '.bold.green + cmd); self.logText.log('console> '.bold.green + cmd);
self.console.executeCmd(cmd, function (_err, result) { self.console.executeCmd(cmd, function (err, result) {
self.logText.log(result); let message = err || result;
self.logText.log(message);
if (cb) { if (cb) {
cb(result); cb(message);
} }
}); });
} }

View File

@ -51,15 +51,15 @@ class IPC {
if (data.action !== action) { if (data.action !== action) {
return; return;
} }
let reply = function(_err, replyData) { let reply = function(error, replyData) {
self.reply(socket, action, replyData); self.reply(socket, action, error, replyData);
}; };
done(data.message, reply, socket); done(data.message, reply, socket);
}); });
} }
reply(client, action, data) { reply(client, action, error, data) {
ipc.server.emit(client, 'message', {action: action, message: data}); ipc.server.emit(client, 'message', {action: action, message: data, error: (error && error.stack)});
} }
listenTo(action, callback) { listenTo(action, callback) {
@ -75,7 +75,7 @@ class IPC {
if (msg.action !== action) { if (msg.action !== action) {
return; return;
} }
cb(null, msg.message); cb(msg.error, msg.message);
}); });
} }

View File

@ -11,12 +11,8 @@ function initContext() {
// for now it is defined here // for now it is defined here
// ====================== // ======================
function doEval(code) { function doEval(code) {
try {
// TODO: add trace log here // TODO: add trace log here
return eval(code); return eval(code);
} catch(e) {
throw new Error(e + "\n" + code);
}
} }
function registerVar(varName, code) { function registerVar(varName, code) {