diff options
author | marzavec <admin@marzavec.com> | 2019-04-28 00:14:46 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-04-28 00:14:46 +0200 |
commit | 6643bb52539f8caf78c10956f4d14bb85d742bff (patch) | |
tree | 51b73f067952aed9f379caf4be7e9ab2b08eaac7 | |
parent | Merge pull request #61 from MinusGix/patch-1 (diff) | |
parent | Merge pull request #1 from MinusGix/patch-3 (diff) | |
download | hackchat-6643bb52539f8caf78c10956f4d14bb85d742bff.tar.gz hackchat-6643bb52539f8caf78c10956f4d14bb85d742bff.zip |
Merge pull request #62 from MinusGix/patch-2
Give greater insight into server errors for server owner
-rw-r--r-- | server/src/scripts/configLib/SetupWizard.js | 6 | ||||
-rw-r--r-- | server/src/serverLib/CommandManager.js | 16 |
2 files changed, 19 insertions, 3 deletions
diff --git a/server/src/scripts/configLib/SetupWizard.js b/server/src/scripts/configLib/SetupWizard.js index 339878d..bd6ef24 100644 --- a/server/src/scripts/configLib/SetupWizard.js +++ b/server/src/scripts/configLib/SetupWizard.js @@ -87,6 +87,12 @@ class SetupWizard { if (typeof result.mods === 'undefined') { result.mods = []; } + + // If we should log errors with the err stack when they occur. + // See: CommandManager.js + if (typeof result.logErrDetailed === 'undefined') { + result.logErrDetailed = false; + } // finally create the actual JSON file try { diff --git a/server/src/serverLib/CommandManager.js b/server/src/serverLib/CommandManager.js index a99d0a9..0c4f0aa 100644 --- a/server/src/serverLib/CommandManager.js +++ b/server/src/serverLib/CommandManager.js @@ -23,6 +23,9 @@ class CommandManager { this.core = core; this.commands = []; this.categories = []; + if (!this.core.config.hasOwnProperty('logErrDetailed')) { + this.core.config.logErrDetailed = false; + } } /** @@ -268,13 +271,20 @@ class CommandManager { try { return await command.run(this.core, server, socket, data); } catch (err) { - let errText = `Failed to execute '${command.info.name}': ${err}`; - console.log(errText); + let errText = `Failed to execute '${command.info.name}': `; + + // If we have more detail enabled, then we get the trace + // if it isn't, or the property doesn't exist, then we'll get only the message + if (this.core.config.logErrDetailed === true) { + console.log(errText + err.stack); + } else { + console.log(errText + err.toString()) + } this.handleCommand(server, socket, { cmd: 'socketreply', cmdKey: server.cmdKey, - text: errText + text: errText + err.toString() }); return null; |