diff --git a/src/lib/error/exceeds-limit-error.ts b/src/lib/error/exceeds-limit-error.ts new file mode 100644 index 0000000000..bb5a24c41f --- /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 565808a48b..3d4741354d 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;