diff --git a/src/lib/error/exceeds-limit-error.ts b/src/lib/error/exceeds-limit-error.ts new file mode 100644 index 00000000000..bb5a24c41ff --- /dev/null +++ b/src/lib/error/exceeds-limit-error.ts @@ -0,0 +1,11 @@ +import { GenericUnleashError } from './unleash-error'; + +export class ExceedsLimitError extends GenericUnleashError { + constructor(resource: string, limit: number) { + super({ + name: 'ExceedsLimitError', + message: `Failed to create ${resource}. You can't create more than the established limit of ${limit}.`, + statusCode: 400, + }); + } +} diff --git a/src/lib/error/unleash-error.ts b/src/lib/error/unleash-error.ts index 565808a48bb..3d4741354d3 100644 --- a/src/lib/error/unleash-error.ts +++ b/src/lib/error/unleash-error.ts @@ -28,7 +28,7 @@ export const UnleashApiErrorTypes = [ 'InvalidTokenError', 'OwaspValidationError', 'ForbiddenError', - + 'ExceedsLimitError', // server errors; not the end user's fault 'InternalError', ] as const;