From 495b8031e3f475a3955a26b3d624793fbc1bd3cc Mon Sep 17 00:00:00 2001 From: Ajay Date: Sun, 30 Jun 2024 09:40:25 -0400 Subject: [PATCH] Add better logging for failed reputation call --- src/utils/reputation.ts | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/utils/reputation.ts b/src/utils/reputation.ts index 906be30..6993f0b 100644 --- a/src/utils/reputation.ts +++ b/src/utils/reputation.ts @@ -47,10 +47,15 @@ export async function getReputation(userID: UserID): Promise { const promise = activeReputationRequests[userID] ?? QueryCacher.get(fetchFromDB, reputationKey(userID)); activeReputationRequests[userID] = promise; - const result = await promise; - delete activeReputationRequests[userID]; + try { + const result = await promise; - return calculateReputationFromMetrics(result); + delete activeReputationRequests[userID]; + + return calculateReputationFromMetrics(result); + } catch (e) { + throw new Error(`${(e as Error)?.message}\n\n${userID}`); + } } // convert a number from one range to another.