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

feat: export error codes as static properties #171

Merged
merged 3 commits into from
Mar 24, 2021

Conversation

alchar
Copy link
Contributor

@alchar alchar commented Mar 23, 2021

This is just to make it possible to get the code, without having to create a new instance of the class.

In our use case, we emit a metric with the error code on some failures. The unit tests look like:

assert(emittedMetric === new JWTExpired("test message").code);

which isn't nearly as clean as:

assert(emittedMetric === JWTExpired.code);

Discussion is here

@panva panva changed the title Add static error codes feat: export error codes as static properties Mar 24, 2021
@panva panva merged commit 89d8003 into panva:main Mar 24, 2021
@alchar alchar deleted the alchar/staticErrorCodes branch March 24, 2021 16:05
@github-actions github-actions bot locked and limited conversation to collaborators Jun 23, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants