From 3bf246beec0ee6a9e6c1f4308acf502974446ff7 Mon Sep 17 00:00:00 2001 From: GuillaumeSD Date: Sun, 29 Dec 2024 18:41:42 +0100 Subject: [PATCH] fix : lichess timeout errors handling --- src/lib/lichess.ts | 7 ++----- src/lib/sentry.ts | 2 +- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/src/lib/lichess.ts b/src/lib/lichess.ts index e45b39c..f832f3d 100644 --- a/src/lib/lichess.ts +++ b/src/lib/lichess.ts @@ -52,11 +52,8 @@ export const getLichessEval = async ( bestMove, lines: linesToKeep, }; - } catch (rawError) { - const error = - rawError instanceof Error ? rawError : new Error("Unknown error"); - - if (error.name !== "AbortError") { + } catch (error) { + if (error !== "timeout") { logErrorToSentry(error, { fen, multiPv }); } diff --git a/src/lib/sentry.ts b/src/lib/sentry.ts index 48d321a..8737869 100644 --- a/src/lib/sentry.ts +++ b/src/lib/sentry.ts @@ -4,7 +4,7 @@ export const isSentryEnabled = () => !!process.env.NEXT_PUBLIC_SENTRY_DSN && Sentry.isInitialized(); export const logErrorToSentry = ( - error: Error, + error: unknown, context?: Record ) => { if (isSentryEnabled()) {