-
Notifications
You must be signed in to change notification settings - Fork 43
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
Add throw new Error('') snippet #38
Comments
How about The |
Hi @extrabacon thanks for quick response :) I think what you are referring to is a generic If you have some rationale for your side please reference them, from my perspective not using |
Yes, we should use Also, it's definitely safe. All built-in error constructors can be used as functions. However, we cannot say the same for subclassed errors, as there is no guarantee that its constructor can be used as a function (unless the implementor added this behavior). Thus, it's only needed in this case. Bonus: it makes it really easy to spot custom errors VS builtin errors, just by using the In terms of snippets, What do you think? |
@extrabacon Thanks for explanation you are right that you can use Error without new as it behaves as factory function. This is really fine with me, my concern is that I think they can promote practice that lack consistency, and because of the you could later make silly errors like e.g. forget to add new for subclassed errors. I'm using an eslint rule to always guard me from this kind of bugs. Regarding snippets I think they look great :) Thanks a lot! |
Using linting is definitely a must if you wish to catch such issues. I will go forward with adding the snippets. |
Hello,
I'm missing throw new snippets could you please add ones for following use cases:
The text was updated successfully, but these errors were encountered: