Server crashes are now dumped to log file.

This commit is contained in:
rainbow napkin 2025-09-06 01:52:21 -04:00
parent cb5f1dbf9b
commit 08d2bf8bc9
101 changed files with 220 additions and 1807 deletions

View file

@ -163,8 +163,6 @@ class playlistHandler{
}
//The UUID is only validated, not processed so we just return the new time :P
console.log(this.channel)
console.log(this.channel.queue);
return this.channel.queue.getStart(data.start)
}

View file

@ -14,6 +14,9 @@ GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.*/
//Node
const fs = require('node:fs/promises');
//Config
const config = require('../../config.json');
@ -64,7 +67,7 @@ module.exports.localExceptionHandler = function(err){
//If we're being verbose
if(config.verbose){
//Log the error
console.log(err)
module.exports.dumpError(err);
}
}
@ -163,4 +166,21 @@ module.exports.errorMiddleware = function(err, req, res, next){
}
module.exports.errorHandler(res, err.message, reason, err.status);
}
/**
* Dumps unexpected server crashes to dedicated log files
* @param {Error} err - error to dump to file
* @param {Date} date - Date of error, defaults to now
*/
module.exports.dumpError = function(err, date = new Date()){
try{
const content = `Error Date: ${date.toLocaleString()} (UTC-${date.getTimezoneOffset()/60})\nError Type: ${err.name}\nError Msg:${err.message}\nStack Trace:\n\n${err.stack}`;
fs.writeFile(`log/crash/${date.getTime()}.log`, content);
}catch(doubleErr){
module.exports.consoleWarn("Yo Dawg, I herd you like errors, so I put an error in your error dump, so you can dump while you dump:");
module.exports.consoleWarn(err);
module.exports.consoleWarn(doubleErr);
}
}