From 670d253a8cfed25042d3e075b944fbef4a7e7bce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gerg=C5=91=20M=C3=B3ricz?= Date: Thu, 22 Aug 2024 14:08:09 +0200 Subject: [PATCH] fix(auth): fix error reporting --- apps/api/src/controllers/auth.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/apps/api/src/controllers/auth.ts b/apps/api/src/controllers/auth.ts index 467d09fc..ac60dc53 100644 --- a/apps/api/src/controllers/auth.ts +++ b/apps/api/src/controllers/auth.ts @@ -61,8 +61,10 @@ async function getKeyAndPriceId(normalizedApi: string): Promise<{ }; } if (!data || data.length === 0) { - Logger.warn(`Error fetching api key: ${error.message} or data is empty`); - Sentry.captureException(error); + if (error) { + Logger.warn(`Error fetching api key: ${error.message} or data is empty`); + Sentry.captureException(error); + } // TODO: change this error code ? return { success: false, @@ -309,8 +311,8 @@ export async function supaAuthenticateUser( if (error || !data || data.length === 0) { if (error) { Sentry.captureException(error); + Logger.warn(`Error fetching api key: ${error.message} or data is empty`); } - Logger.warn(`Error fetching api key: ${error.message} or data is empty`); return { success: false, error: "Unauthorized: Invalid token",