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:
parent
8a67640aed
commit
feb6825023
11
src/lib/error/exceeds-limit-error.ts
Normal file
11
src/lib/error/exceeds-limit-error.ts
Normal 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,
|
||||
});
|
||||
}
|
||||
}
|
@ -28,7 +28,7 @@ export const UnleashApiErrorTypes = [
|
||||
'InvalidTokenError',
|
||||
'OwaspValidationError',
|
||||
'ForbiddenError',
|
||||
|
||||
'ExceedsLimitError',
|
||||
// server errors; not the end user's fault
|
||||
'InternalError',
|
||||
] as const;
|
||||
|
Loading…
Reference in New Issue
Block a user