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

Deprecate errcode(String, ...) #19

Closed
achingbrain opened this issue Jul 11, 2019 · 3 comments · Fixed by #20
Closed

Deprecate errcode(String, ...) #19

achingbrain opened this issue Jul 11, 2019 · 3 comments · Fixed by #20

Comments

@achingbrain
Copy link
Collaborator

If you pass a string as the first argument, this module will new up an Error for us, which is convenient and all but means the stack trace for the error starts in the err-code module and not at the throw site.

This leads to developer confusion as there are irrelevant lines in the stack trace, and also leaks internal implementation details of the calling code (e.g. that err-code is used) which seems like an anti-pattern.

Accepting a string as the first argument should be deprecated and removed in a future release in favour of passing in Error objects.

What do you think?

@satazor
Copy link
Member

satazor commented Jul 12, 2019

I agree! Let’s remove the support for it as a breaking change and bump the major. Wanna do a PR?

achingbrain added a commit to achingbrain/js-err-code that referenced this issue Jul 12, 2019
If other types are passed in, a new `Error` object is created by this
module which results in misleading stack traces.

Closes IndigoUnited#19
@achingbrain
Copy link
Collaborator Author

Done! See #20

achingbrain added a commit to achingbrain/js-err-code that referenced this issue Jul 15, 2019
If other types are passed in, a new `Error` object is created by this
module which results in misleading stack traces.

Closes IndigoUnited#19
achingbrain added a commit to achingbrain/js-err-code that referenced this issue Jul 15, 2019
If other types are passed in, a new `Error` object is created by this
module which results in misleading stack traces.

Closes IndigoUnited#19
satazor pushed a commit that referenced this issue Jul 15, 2019
If other types are passed in, a new `Error` object is created by this
module which results in misleading stack traces.

Closes #19
@gabssnake
Copy link

Hi there !
Have you considered using Error.captureStackTrace to provide String support without the additional stack entry ?
Happy to propose some code if you're open to that :)
Best,

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

Successfully merging a pull request may close this issue.

3 participants