mirror of
https://github.com/hack-chat/main.git
synced 2024-03-22 13:20:33 +08:00
Merge pull request #62 from MinusGix/patch-2
Give greater insight into server errors for server owner
This commit is contained in:
commit
6643bb5253
|
@ -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 {
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue
Block a user