Handle plugin load errors gracefully

This commit is contained in:
Dragory 2020-07-30 20:40:00 +03:00
parent fcc3c17b73
commit 557898e484
No known key found for this signature in database
GPG key ID: 5F387BA66DF8AAC1
4 changed files with 38 additions and 18 deletions

View file

@ -21,6 +21,7 @@ import { GuildLogs } from "./data/GuildLogs";
import { LogType } from "./data/LogType";
import { ZeppelinPlugin } from "./plugins/ZeppelinPlugin";
import { logger } from "./logger";
import { PluginLoadError } from "knub/dist/plugins/PluginLoadError";
const fsp = fs.promises;
@ -59,6 +60,12 @@ if (process.env.NODE_ENV === "production") {
return;
}
if (err instanceof PluginLoadError) {
// tslint:disable:no-console
console.warn(`${err.guild.name} (${err.guild.id}): Failed to load plugin '${err.pluginName}': ${err.message}`);
return;
}
// tslint:disable:no-console
console.error(err);