Log in console when we crash due to too many recent errors
This commit is contained in:
parent
64dd1fc9e0
commit
3b340a92c1
1 changed files with 8 additions and 2 deletions
10
src/index.ts
10
src/index.ts
|
@ -26,11 +26,17 @@ function errorHandler(err) {
|
|||
|
||||
if (err instanceof PluginError) {
|
||||
// Tolerate a few recent plugin errors before crashing
|
||||
if (++recentPluginErrors >= RECENT_PLUGIN_ERROR_EXIT_THRESHOLD) process.exit(1);
|
||||
if (++recentPluginErrors >= RECENT_PLUGIN_ERROR_EXIT_THRESHOLD) {
|
||||
console.error(`Exiting after ${RECENT_PLUGIN_ERROR_EXIT_THRESHOLD} plugin errors`);
|
||||
process.exit(1);
|
||||
}
|
||||
} else if (err instanceof DiscordRESTError || err instanceof DiscordHTTPError) {
|
||||
// Discord API errors, usually safe to continue (rate limits etc. are handled elsewhere)
|
||||
// We still bail if we get a ton of them in a short amount of time
|
||||
if (++recentDiscordErrors >= RECENT_DISCORD_ERROR_EXIT_THRESHOLD) process.exit(1);
|
||||
if (++recentDiscordErrors >= RECENT_DISCORD_ERROR_EXIT_THRESHOLD) {
|
||||
console.error(`Exiting after ${RECENT_DISCORD_ERROR_EXIT_THRESHOLD} API errors`);
|
||||
process.exit(1);
|
||||
}
|
||||
} else {
|
||||
// On other errors, crash immediately
|
||||
process.exit(1);
|
||||
|
|
Loading…
Add table
Reference in a new issue