chore(gatekeeper): add specific error for unsupported workspace plan

This commit is contained in:
Alessandro Magionami
2025-03-13 10:36:28 +01:00
parent 89519bc6b7
commit d829cac8b3
2 changed files with 10 additions and 1 deletions
@@ -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
}
@@ -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) {