From 86b1717ba36bb0c47b60b556d3a44e49669a5f57 Mon Sep 17 00:00:00 2001 From: ChrisChrome Date: Sun, 12 May 2024 06:41:21 -0600 Subject: [PATCH] I just woke up, it died last night, just gonna mke it crash when it does. Also log all errors for a file --- index.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/index.js b/index.js index a2fa606..9a259a4 100644 --- a/index.js +++ b/index.js @@ -1,4 +1,5 @@ // Requires +const fs = require("fs"); const config = require("./config.json"); const wfos = require("./wfos.json"); const iem = require("./iem.json"); @@ -1154,6 +1155,9 @@ discord.on("guildDelete", (guild) => { process.on("unhandledRejection", (error) => { console.log(`${colors.red("[ERROR]")} Unhandled Rejection: ${error.stack}`); + // write ./error/rejection_timestamp.txt + fs.writeFileSync(`./error/rejection_${Date.now()}.txt`, error.stack); + process.exit(1); if (false) { fetch(config.ntfy.server, { method: 'POST', @@ -1174,6 +1178,9 @@ process.on("unhandledRejection", (error) => { process.on("uncaughtException", (error) => { console.log(`${colors.red("[ERROR]")} Uncaught Exception: ${error.message}\n${error.stack}`); + // write ./error/exception_timestamp.txt + fs.writeFileSync(`./error/exception_${Date.now()}.txt`, error.stack); + process.exit(1); if (false) { fetch(config.ntfy.server, { method: 'POST',