Skip to content

Commit

Permalink
cleanup:
Browse files Browse the repository at this point in the history
  • Loading branch information
grahamlangford committed Apr 30, 2024
1 parent a40ac22 commit de68cab
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions src/contrib/google/sheets/core/handleGoogleRequestRejection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,6 @@ export async function handleGoogleRequestRejection(
error: unknown,
googleAccount: Nullishable<SanitizedIntegrationConfig>,
): 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 = selectAxiosError(error);

console.log({ rootCause: JSON.stringify(rootCause, null, 2) });

console.debug("Error making Google request", {
error,
});
Expand All @@ -55,12 +49,16 @@ export async function handleGoogleRequestRejection(
});
}

if (!isAxiosError(rootCause) || rootCause.response == null) {
// Request errors from proxyRequest are wrapped in ContextError which includes metadata about the integration
// configuration. Therefore, get axios error if it exists.
const axiosError = selectAxiosError(error);

if (axiosError.response == null) {
// It should always be an error-like object at this point, but be defensive.
return selectError(error);
}

const { status } = rootCause.response;
const { status } = axiosError.response;

if ([403, 404].includes(status)) {
const message =
Expand Down

0 comments on commit de68cab

Please sign in to comment.