From 39dd400b1ebd0013373288794d343bde498b95b4 Mon Sep 17 00:00:00 2001 From: Branden Rodgers Date: Tue, 30 Jul 2024 16:59:30 -0400 Subject: [PATCH] Remove custom project 403 error handlers --- errors/apiErrors.ts | 22 ++-------------------- lang/en.json | 2 -- types/Error.ts | 1 - 3 files changed, 2 insertions(+), 23 deletions(-) diff --git a/errors/apiErrors.ts b/errors/apiErrors.ts index 6b793c28..2b9d4e63 100644 --- a/errors/apiErrors.ts +++ b/errors/apiErrors.ts @@ -130,7 +130,6 @@ export function getAxiosErrorWithContext( ): Error { const status = error.response?.status; const method = error.config?.method as HttpMethod; - const { projectName } = context; let messageDetail: string; @@ -161,9 +160,6 @@ export function getAxiosErrorWithContext( i18n(`${i18nKey}.unableToUpload`, { payload: context.payload }) ); } - const isProjectMissingScopeError = - isMissingScopeError(error) && !!projectName; - const isProjectGatingError = isGatingError(error) && !!projectName; switch (status) { case 400: @@ -173,21 +169,7 @@ export function getAxiosErrorWithContext( errorMessage.push(i18n(`${i18nKey}.codes.401`, { messageDetail })); break; case 403: - if (isProjectMissingScopeError) { - errorMessage.push( - i18n(`${i18nKey}.codes.403ProjectMissingScope`, { - accountId: context.accountId || '', - }) - ); - } else if (isProjectGatingError) { - errorMessage.push( - i18n(`${i18nKey}.codes.403ProjectGating`, { - accountId: context.accountId || '', - }) - ); - } else { - errorMessage.push(i18n(`${i18nKey}.codes.403`, { messageDetail })); - } + errorMessage.push(i18n(`${i18nKey}.codes.403`, { messageDetail })); break; case 404: errorMessage.push(i18n(`${i18nKey}.codes.404`, { messageDetail })); @@ -216,7 +198,7 @@ export function getAxiosErrorWithContext( if (error?.response?.data) { const { message, errors } = error.response.data; - if (message && !isProjectMissingScopeError && !isProjectGatingError) { + if (message) { errorMessage.push(message); } diff --git a/lang/en.json b/lang/en.json index bbd2fef6..1f431971 100644 --- a/lang/en.json +++ b/lang/en.json @@ -379,8 +379,6 @@ "404": "The {{ messageDetail }} was not found.", "429": "The {{ messageDetail }} surpassed the rate limit. Retry in one minute.", "503": "The {{ messageDetail }} could not be handled at this time. Please try again or visit https://help.hubspot.com/ to submit a ticket or contact HubSpot Support if the issue persists.", - "403ProjectMissingScope": "Couldn't run the project command because there are scopes missing in your production account. To update scopes, deactivate your current personal access key for {{ accountId }}, and generate a new one. Then run `hs auth` to update the CLI with the new key.", - "403ProjectGating": "The current target account {{ accountId }} does not have access to HubSpot projects. To opt in to the CRM Development Beta and use projects, visit https://app.hubspot.com/l/product-updates/in-beta?update=13899236.", "500Generic": "The {{ messageDetail }} failed due to a server error. Please try again or visit https://help.hubspot.com/ to submit a ticket or contact HubSpot Support if the issue persists.", "400Generic": "The {{ messageDetail }} failed due to a client error.", "generic": "The {{ messageDetail }} failed." diff --git a/types/Error.ts b/types/Error.ts index 555d553c..9fe0981c 100644 --- a/types/Error.ts +++ b/types/Error.ts @@ -34,7 +34,6 @@ export type AxiosErrorContext = { accountId?: number; request?: string; payload?: string; - projectName?: string; }; export type OptionalError = BaseError | null | undefined;