Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 3 commits into from
Mar 6, 2024

Conversation

gastonfournier
Copy link
Contributor

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:

export const UnleashApiErrorTypes = [
'ContentTypeError',
'DisabledError',
'FeatureHasTagError',
'IncompatibleProjectError',
'InvalidOperationError',
'InvalidTokenError',
'MinimumOneEnvironmentError',
'NameExistsError',
'NoAccessError',
'NotFoundError',
'NotImplementedError',
'OperationDeniedError',
'PasswordMismatch',
'PasswordUndefinedError',
'ProjectWithoutOwnerError',
'RoleInUseError',
'UnknownError',
'UsedTokenError',
'BadDataError',
'ValidationError',
'AuthenticationRequired',
'UnauthorizedError',
'PermissionError',
'InvalidTokenError',
'OwaspValidationError',
'ForbiddenError',
// server errors; not the end user's fault
'InternalError',
] as const;

Copy link

vercel bot commented Mar 6, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
unleash-monorepo-frontend ✅ Ready (Inspect) Visit Preview 💬 Add feedback Mar 6, 2024 6:12pm
1 Ignored Deployment
Name Status Preview Comments Updated (UTC)
unleash-docs ⬜️ Ignored (Inspect) Visit Preview Mar 6, 2024 6:12pm

export class ExeedsLimitError extends GenericUnleashError {
constructor(resource: string, limit: number) {
super({
name: 'ValidationError', // it can also be 'OperationDeniedError' or we can create a new one
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not call it ExceedsLimitError?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did, let's see how it goes :D

Copy link
Member

@nunogois nunogois left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is a good starting point! Still, I think it's worth taking the comments into consideration before merging it.

@gastonfournier gastonfournier merged commit feb6825 into main Mar 6, 2024
13 checks passed
@gastonfournier gastonfournier deleted the chore/add-new-error-for-exeed-limits branch March 6, 2024 18:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

None yet

2 participants