From be1c327093e39d6a908b9ac95e8bcead36aeb4ca Mon Sep 17 00:00:00 2001 From: Dragory Date: Fri, 3 Aug 2018 19:25:00 +0300 Subject: [PATCH] Don't crash on Discord HTTP errors --- src/index.ts | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/index.ts b/src/index.ts index f6e6a4fc..db39d9b9 100644 --- a/src/index.ts +++ b/src/index.ts @@ -6,6 +6,16 @@ process.on("unhandledRejection", (reason, p) => { process.exit(1); }); +process.on("uncaughtException", err => { + if (err.message && err.message.startsWith("DiscordHTTPError")) { + console.error(err); + return; + } else { + console.error(err); + process.exit(1); + } +}); + // Always use UTC // This is also set for the database in knexfile import moment from "moment-timezone";