talawa-api icon indicating copy to clipboard operation
talawa-api copied to clipboard

Adding constants for the error messages that are passed as direct values

Open Manoramsharma opened this issue 2 years ago • 12 comments

Actually there are constant values that are already defined for the different values of error message/code/param that are then further used by importing the src/constants folder, in the particular file but there are still some errors for which we are using direct values of message/param/code instead of already assigning the constants then using the same. For instance,

requestContext.translate("invalid.refreshToken"),
          code: "invalid.refreshToken",
          param: "refreshToken",
requestContext.translate("invalid.credentials"),
          code: "invalid.credentials",
          param: "credentials",

Describe the solution you'd like As the solution to this given problem it is more likely to create constants named

INVALID_REFRESH_TOKEN="Invalid Refresh token", 
INVALID_REFRESH_TOKEN_MESSAGE="invalid.refreshToken",
INVALID_REFRESH_TOKEN_CODE="invalid.refreshToken"
INVALID_REFRESH_TOKEN_PARAM="credentials"
``` in the src/constants folder and then using them anywhere required.

**Approach to be followed (optional)**
Just add and export the constant values for the given error message/code/param in the src/constants folder.

Manoramsharma avatar Feb 09 '23 05:02 Manoramsharma

Congratulations on making your first Issue! :confetti_ball: If you haven't already, check out our Contributing Guidelines and Issue Reporting Guidelines to ensure that you are following our guidelines for contributing and making issues.

github-actions[bot] avatar Feb 09 '23 05:02 github-actions[bot]

Hi @noman2002 @palisadoes requires review on this issue.If approved I would like to work on this.

Manoramsharma avatar Feb 09 '23 05:02 Manoramsharma

There are other files also with same issue , I would also like to work on this issue . @palisadoes @noman

aashimawadhwa avatar Feb 09 '23 10:02 aashimawadhwa

This is a great suggestion, this would give a more consistent approach to testing as previously it felt inconsistent while writing tests for catching errors with hardcoded -strings.

kb-0311 avatar Feb 09 '23 13:02 kb-0311

@Manoramsharma is this issue only on specific files or whole project. if its on specific file please mention the file name.

noman2002 avatar Feb 09 '23 18:02 noman2002

@Manoramsharma This should be done for the whole project so reduce the PR workload.

palisadoes avatar Feb 09 '23 18:02 palisadoes

@Manoramsharma This should be done for the whole project so reduce the PR workload.

Create child issues for each directory, and let others work too. It will be easier to track.

noman2002 avatar Feb 09 '23 18:02 noman2002

@Manoramsharma This should be done for the whole project so reduce the PR workload.

Create child issues for each directory, and let others work too. It will be easier to track.

should I create the children issue?

aashimawadhwa avatar Feb 09 '23 18:02 aashimawadhwa

@Manoramsharma This should be done for the whole project so reduce the PR workload.

Create child issues for each directory, and let others work too. It will be easier to track.

should I create the children issue?

I may help you with this task. Either you create child issues, or I may help you with that.

anshgoyalevil avatar Feb 09 '23 18:02 anshgoyalevil

@Manoramsharma This should be done for the whole project so reduce the PR workload.

Create child issues for each directory, and let others work too. It will be easier to track.

should I create the children issue?

@aashimawadhwa Please proceed

palisadoes avatar Feb 09 '23 18:02 palisadoes

I could help with children issues also

kb-0311 avatar Feb 09 '23 18:02 kb-0311

@Manoramsharma is this issue only on specific files or whole project. if its on specific file please mention the file name.

No this will be done for the complete project.

Manoramsharma avatar Feb 09 '23 20:02 Manoramsharma

Can I work on this issue??

Ramneet04 avatar Aug 15 '24 21:08 Ramneet04