Conversation
shivamvijaywargi
left a comment
There was a problem hiding this comment.
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.
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.
Yes this is a good idea. This way error will be more precise and easy to build.
There was a problem hiding this comment.
@ubprudhvi Please follow this and update the PR.
src/modules/auth/auth.routes.ts
Outdated
| message: z.string(), | ||
| }), | ||
| "Server side error(s)", | ||
| SERVER_ERROR, |
There was a problem hiding this comment.
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.
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.
We already have an unauthorised error message constant.
| @@ -8,5 +10,7 @@ export const AUTHORIZATION_ERROR_MESSAGE | |||
| export const FORBIDDEN_ERROR_MESSAGE | |||
| = "You are not allowed to perform this action."; | |||
There was a problem hiding this comment.
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.
We should probably have an enum for resourceName.



No description provided.