mirror of
https://github.com/ZeppelinBot/Zeppelin.git
synced 2025-03-14 21:31:50 +00:00
Don'Ãt exit on errors unless there have been a lot of them recently
This commit is contained in:
parent
34ad8fab8b
commit
dcb00d74f8
1 changed files with 7 additions and 9 deletions
16
src/index.ts
16
src/index.ts
|
@ -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);
|
||||
}
|
||||
console.error(err);
|
||||
if (++recentErrors >= RECENT_ERROR_EXIT_THRESHOLD) process.exit(1);
|
||||
});
|
||||
|
||||
// Verify required Node.js version
|
||||
|
|
Loading…
Add table
Reference in a new issue