From d829cac8b3f9ded0a3bd3f41fa9043a66a75c737 Mon Sep 17 00:00:00 2001 From: Alessandro Magionami Date: Thu, 13 Mar 2025 10:36:28 +0100 Subject: [PATCH] chore(gatekeeper): add specific error for unsupported workspace plan --- packages/server/modules/gatekeeper/errors/billing.ts | 6 ++++++ .../services/subscriptions/upgradeWorkspaceSubscription.ts | 5 ++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/packages/server/modules/gatekeeper/errors/billing.ts b/packages/server/modules/gatekeeper/errors/billing.ts index 0f0a78e03..dc5e5e31a 100644 --- a/packages/server/modules/gatekeeper/errors/billing.ts +++ b/packages/server/modules/gatekeeper/errors/billing.ts @@ -71,3 +71,9 @@ export class InvalidBillingIntervalError extends BaseError { static code = 'INVALID_BILLING_INTERVAL' static statusCode = 400 } + +export class UnsupportedWorkspacePlanError extends BaseError { + static defaultMessage = 'Unsupported workspace plan' + static code = 'UNSUPPORTED_WORKSPACE_PLAN_ERROR' + static statusCode = 400 +} diff --git a/packages/server/modules/gatekeeper/services/subscriptions/upgradeWorkspaceSubscription.ts b/packages/server/modules/gatekeeper/services/subscriptions/upgradeWorkspaceSubscription.ts index 5c4956e12..d9a22dc73 100644 --- a/packages/server/modules/gatekeeper/services/subscriptions/upgradeWorkspaceSubscription.ts +++ b/packages/server/modules/gatekeeper/services/subscriptions/upgradeWorkspaceSubscription.ts @@ -11,6 +11,7 @@ import { import { CountSeatsByTypeInWorkspace } from '@/modules/gatekeeper/domain/operations' import { InvalidWorkspacePlanUpgradeError, + UnsupportedWorkspacePlanError, WorkspaceNotPaidPlanError, WorkspacePlanMismatchError, WorkspacePlanNotFoundError, @@ -265,7 +266,9 @@ export const upgradeWorkspaceSubscriptionFactoryNew = if (!workspacePlan) throw new WorkspacePlanNotFoundError() if (!isNewPlanType(workspacePlan.name) || !isNewPlanType(targetPlan)) { - throw new NotImplementedError() + throw new UnsupportedWorkspacePlanError(null, { + info: { currentPlan: workspacePlan.name, targetPlan } + }) } switch (workspacePlan.name) {