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

Always throw error objects instead of strings #412

Merged
merged 2 commits into from Nov 2, 2020

Conversation

Gekkio
Copy link
Contributor

@Gekkio Gekkio commented Jan 15, 2020

While JS technically allows code to throw anything (including undefined/null/NaN), it's often considered bad practice. It's very annoying to handle/log errors from a library that sometimes throws strings and sometimes objects, and there's also no stack trace in string errors to help with debugging.

I realize this might be a controversial change, and it can break existing error handling code that assumes strings are thrown in some of the cases. But maybe it could be at least considered for 2.0?

More information:

https://eslint.org/docs/rules/no-throw-literal
http://bluebirdjs.com/docs/warning-explanations.html#warning-a-promise-was-rejected-with-a-non-error

@markstos markstos added 2.0 breaking-change Not backwards compatible. Requires major version bump. labels Jan 20, 2020
@markstos
Copy link
Contributor

markstos commented Jan 20, 2020

I'm in agreement with this, and agree it would be a "breaking change" for some.

@Gekkio Could your review what our docs say about the exceptions we throw and make sure they reflect the change as well?

@markstos
Copy link
Contributor

I agree with this change. I was going to save it a for a bundled "2.0" release, but clearly that approach didn't work. If you'll address the merge conflicts, I'll try to get it out sooner, which may possibly mean moving away from a bundled 2.0 release to a series of breaking change releases.

While JS *technically* allows code to throw anything (including
undefined/null/NaN), it's often considered bad practice.
@Gekkio
Copy link
Contributor Author

Gekkio commented Oct 30, 2020

Sorry, I completely forgot about this pull request 😅

I've rebased the changes on top of current master, so the pull request is now up-to-date. I also looked at the docs and couldn't find a detailed description of thrown errors that would need to be changed, so the docs seem ok to me.

test/tests.js Outdated Show resolved Hide resolved
@markstos
Copy link
Contributor

@cjbarth Even though we didn't document the error format returned, I still think we should do a major version bump for this change. Would you agree?

@cjbarth
Copy link
Collaborator

cjbarth commented Oct 30, 2020

I completely agree. This already has the 2.0 and breaking-change tags, so I think we are good to honor that. Once this is totally ready to land we can discuss what else might be good for a 2.0 release.

@markstos markstos self-requested a review October 30, 2020 19:12
@markstos
Copy link
Contributor

markstos commented Nov 2, 2020

We are planning a 2.0 release today, so I'm merging this.

@markstos markstos merged commit 8678139 into node-saml:master Nov 2, 2020
davidmehren added a commit to hedgedoc/hedgedoc that referenced this pull request Feb 11, 2021
As stated in https://github.com/node-saml/passport-saml/blob/master/CHANGELOG.md#v200-2020-11-03
and the corresponding PR node-saml/passport-saml#412
passport-saml now always throws error objects instead of strings.
This fixes our error logging to accommodate this change.

Signed-off-by: David Mehren <git@herrmehren.de>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking-change Not backwards compatible. Requires major version bump.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants