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

Define error messages as exportable constants #241

Open
cre8 opened this issue May 21, 2024 · 1 comment
Open

Define error messages as exportable constants #241

cre8 opened this issue May 21, 2024 · 1 comment
Assignees

Comments

@cre8
Copy link
Contributor

cre8 commented May 21, 2024

Sometimes we need to find out which error was thrown. To avoid a break of our application when we change the string of the error message, we should use constants that we use for throwing an error and that can be used by a developper for checking it like

const STATUS_NOT_VALID = "Status is not valid";
...
throw new Error(STATUS_NOT_VALID)
...
catch(e) {
if(e.message === STATUS_NOT_VALID)
}
@lukasjhan
Copy link
Member

It's a good idea.

Since the error message variables may be the same, let's include the namespace with it. such as:

catch(e) {
    if(e.message === SD_JWT_ERROR.STATUS_NOT_VALID)
}

@lukasjhan lukasjhan self-assigned this Jun 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants