fix: fix not being able to catch Phisherman API call errors

This commit is contained in:
Dragory 2021-11-01 17:09:02 +02:00
parent b162d8c72e
commit 1081d1b361
No known key found for this signature in database
GPG key ID: 5F387BA66DF8AAC1
2 changed files with 23 additions and 7 deletions

View file

@ -37,13 +37,20 @@ export const PhishermanPlugin = zeppelinGuildPlugin<PhishermanPluginType>()({
if (!hasPhishermanMasterAPIKey()) {
// tslint:disable-next-line:no-console
console.warn("Could not load Phisherman plugin: master API key is missing");
console.warn("[PHISHERMAN] Could not load Phisherman plugin: master API key is missing");
return;
}
const apiKey = pluginData.config.get().api_key;
if (apiKey && (await phishermanApiKeyIsValid(apiKey).catch(() => false))) {
pluginData.state.validApiKey = apiKey;
if (apiKey) {
const isValid = await phishermanApiKeyIsValid(apiKey).catch((err) => {
// tslint:disable-next-line:no-console
console.warn(`[PHISHERMAN] Error checking user API key validity:\n${err.toString()}`);
return false;
});
if (isValid) {
pluginData.state.validApiKey = apiKey;
}
}
},
});