-
Notifications
You must be signed in to change notification settings - Fork 1
error msg constants #89
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
base: main
Are you sure you want to change the base?
error msg constants #89
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎉 Thanks for opening your first pull request! We really appreciate your contribution to making this project better. We'll review your changes and get back to you soon.
shivamvijaywargi
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good work and welcome on board🎉
src/common/utils/constants.ts
Outdated
| = "Something went wrong, please try again later"; | ||
| export const VALIDATION_ERROR_MESSAGE = "The validation error(s)"; | ||
| export const SERVER_ERROR = "Server side error(s)"; | ||
| export const GROUP_DOESNT_EXIST = "Group with id does not exist"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about we have a function for these messages and where and when needed we will pass the params and put them in place?
export const RESOURCE_NOT_FOUND = (resourceName: string, resourceId: string) => ${resourceName} with id ${resourceId} does not exist;
And for the common messages we will have no arguments to the function just to stay consistent.
@GenieWizards/work-o-holics Any thoughts on this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes this is a good idea. This way error will be more precise and easy to build.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ubprudhvi Please follow this and update the PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok
src/modules/auth/auth.routes.ts
Outdated
| message: z.string(), | ||
| }), | ||
| "Server side error(s)", | ||
| SERVER_ERROR, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For this we should have INTERNAL_SERVER_ERROR which should say 'Something went wrong, please try again.'.
|
shivamvijaywargi
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, please resolve merge conflicts.
| = "Something went wrong, please try again later"; | ||
| = "Something went wrong, please try again later."; | ||
| export const VALIDATION_ERROR_MESSAGE = "The validation error(s)"; | ||
| export const NOT_AUTHORIZED = "User is not authorized"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We already have an unauthorised error message constant.
| export const AUTHORIZATION_ERROR_MESSAGE | ||
| = "You are not authorized, please login."; | ||
| export const FORBIDDEN_ERROR_MESSAGE | ||
| = "You are not allowed to perform this action."; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For these static messages also better to have them as functions for consistency
Eg: () => 'Error message';
| = "Something went wrong, please try again later."; | ||
| export const VALIDATION_ERROR_MESSAGE = "The validation error(s)"; | ||
| export const NOT_AUTHORIZED = "User is not authorized"; | ||
| export const RESOURCE_NOT_FOUND = (resourceName: string, resourceId: ZodString) => `${resourceName} with id ${resourceId} does not exist`; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should probably have an enum for resourceName.



No description provided.