3
0
Fork 0
mirror of https://github.com/ZeppelinBot/Zeppelin.git synced 2025-03-15 05:41:51 +00:00

Don'Ãt exit on errors unless there have been a lot of them recently

This commit is contained in:
Dragory 2019-01-13 16:52:00 +02:00
parent 34ad8fab8b
commit dcb00d74f8

View file

@ -8,20 +8,18 @@ import { SimpleError } from "./SimpleError";
require("dotenv").config();
let recentErrors = 0;
const RECENT_ERROR_EXIT_THRESHOLD = 5;
setInterval(() => recentErrors--, 2500);
process.on("unhandledRejection", (reason, p) => {
// tslint:disable-next-line
console.error(reason);
process.exit(1);
if (++recentErrors >= RECENT_ERROR_EXIT_THRESHOLD) 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);
}
if (++recentErrors >= RECENT_ERROR_EXIT_THRESHOLD) process.exit(1);
});
// Verify required Node.js version