From 4549da9ba354896d1bb955a83a2e615a52aaa418 Mon Sep 17 00:00:00 2001 From: Bsian Date: Mon, 20 Jan 2020 23:01:01 +0000 Subject: [PATCH] Better error handling --- src/functions/checkSS.ts | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/functions/checkSS.ts b/src/functions/checkSS.ts index 3a8e75e..e6ed824 100644 --- a/src/functions/checkSS.ts +++ b/src/functions/checkSS.ts @@ -23,10 +23,14 @@ export default function checkSS(client: Client) { } } catch (error) { if (!hash) return; - const { status } = error.response; - if (status === 400 || status === 401 || status === 403 || status === 404) { - await client.db.Account.updateOne({ userID }, { $set: { hash: false } }); - client.getDMChannel(userID).then((channel) => channel.createMessage('Your SecureSign password has been reset - please reinitialize your SecureSign account. Run `=securesign init` for more information')).catch(); + try { + const { status } = error.response; + if (status === 400 || status === 401 || status === 403 || status === 404) { + await client.db.Account.updateOne({ userID }, { $set: { hash: false } }); + client.getDMChannel(userID).then((channel) => channel.createMessage('Your SecureSign password has been reset - please reinitialize your SecureSign account. Run `=securesign init` for more information')).catch(); + } + } catch (e) { + throw error; } } }