From 785813f495b56c8ee5586104ba5cacffb093a372 Mon Sep 17 00:00:00 2001 From: Dragory <2606411+Dragory@users.noreply.github.com> Date: Thu, 17 Dec 2020 03:51:59 +0200 Subject: [PATCH] Clean up HTTP 500 errors in stderr --- backend/src/index.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/backend/src/index.ts b/backend/src/index.ts index 2b584fe7..bac28fcd 100644 --- a/backend/src/index.ts +++ b/backend/src/index.ts @@ -11,7 +11,7 @@ import { Configs } from "./data/Configs"; // Always use UTC internally // This is also enforced for the database in data/db.ts import moment from "moment-timezone"; -import { Client, TextChannel } from "eris"; +import { Client, DiscordHTTPError, TextChannel } from "eris"; import { connect } from "./data/db"; import { baseGuildPlugins, globalPlugins, guildPlugins } from "./plugins/availablePlugins"; import { errorMessage, isDiscordHTTPError, isDiscordRESTError, MINUTES, successMessage } from "./utils"; @@ -77,6 +77,12 @@ if (process.env.NODE_ENV === "production") { return; } + if (err instanceof DiscordHTTPError && err.code === 500) { + // Don't need stack traces on HTTP 500 errors + console.error(err.message); + return; + } + // tslint:disable:no-console console.error(err);