From a40ac225c932658795615e6a6596cc64faafe0f2 Mon Sep 17 00:00:00 2001 From: Graham Langford Date: Tue, 30 Apr 2024 14:26:31 -0500 Subject: [PATCH] fix failing tests --- .../sheets/core/handleGoogleRequestRejection.ts | 15 ++++++++------- src/errors/errorHelpers.ts | 1 + 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/contrib/google/sheets/core/handleGoogleRequestRejection.ts b/src/contrib/google/sheets/core/handleGoogleRequestRejection.ts index 53911c793c..8f760f9364 100644 --- a/src/contrib/google/sheets/core/handleGoogleRequestRejection.ts +++ b/src/contrib/google/sheets/core/handleGoogleRequestRejection.ts @@ -16,15 +16,12 @@ */ import { type SanitizedIntegrationConfig } from "@/integrations/integrationTypes"; -import { - getErrorMessage, - getRootCause, - selectError, -} from "@/errors/errorHelpers"; +import { getErrorMessage, selectError } from "@/errors/errorHelpers"; import { isObject } from "@/utils/objectUtils"; import { isAxiosError } from "@/errors/networkErrorHelpers"; import { deleteCachedAuthData } from "@/background/messenger/strict/api"; import { type Nullishable } from "@/utils/nullishUtils"; +import { selectAxiosError } from "@/data/service/requestErrorUtils"; class PermissionsError extends Error { override name = "PermissionsError"; @@ -43,9 +40,13 @@ export async function handleGoogleRequestRejection( ): Promise { // Request errors from proxyRequest are wrapped in ContextError which includes metadata about the integration // configuration. Therefore, get root cause for determining if this is an Axios error - const rootCause = getRootCause(error); + const rootCause = selectAxiosError(error); - console.debug("Error making Google request", { error }); + console.log({ rootCause: JSON.stringify(rootCause, null, 2) }); + + console.debug("Error making Google request", { + error, + }); if (!isObject(error)) { // Shouldn't happen in practice, but be defensive diff --git a/src/errors/errorHelpers.ts b/src/errors/errorHelpers.ts index c62b5fdb91..2cef5facfd 100644 --- a/src/errors/errorHelpers.ts +++ b/src/errors/errorHelpers.ts @@ -144,6 +144,7 @@ export function selectSpecificError< */ export function getRootCause(error: unknown): unknown { while (isErrorObject(error) && error.cause) { + console.log("get root cause", error); error = error.cause; }