1
0
mirror of https://github.com/Unleash/unleash.git synced 2024-12-22 19:07:54 +01:00

chore: add a generic error for limit's exeeded (#6452)

## About the changes
We don't have a meaningful error for limits established by the
application. This could be a good starting point.

The error code is 400 cause I couldn't find anything better. 

The name of the error was picked from UnleashApiErrorTypes:
2d8e9f87ff/src/lib/error/unleash-error.ts (L4-L34)
This commit is contained in:
Gastón Fournier 2024-03-06 19:17:31 +01:00 committed by GitHub
parent 8a67640aed
commit feb6825023
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 12 additions and 1 deletions

View File

@ -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,
});
}
}

View File

@ -28,7 +28,7 @@ export const UnleashApiErrorTypes = [
'InvalidTokenError', 'InvalidTokenError',
'OwaspValidationError', 'OwaspValidationError',
'ForbiddenError', 'ForbiddenError',
'ExceedsLimitError',
// server errors; not the end user's fault // server errors; not the end user's fault
'InternalError', 'InternalError',
] as const; ] as const;