Skip to content

Commit

Permalink
fix failing tests
Browse files Browse the repository at this point in the history
  • Loading branch information
grahamlangford committed Apr 30, 2024
1 parent 8e4dd62 commit a40ac22
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
15 changes: 8 additions & 7 deletions src/contrib/google/sheets/core/handleGoogleRequestRejection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand All @@ -43,9 +40,13 @@ export async function handleGoogleRequestRejection(
): Promise<Error> {
// 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
Expand Down
1 change: 1 addition & 0 deletions src/errors/errorHelpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down

0 comments on commit a40ac22

Please sign in to comment.