| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
There was a problem hiding this comment.
The text above this example needs to be re-written now as well as the example on line 778 as well. Rather than moving the third argument to a comment, perhaps just remove it entirely. The user should still be cautioned against using a string for the expected error message because a string will be interpreted as the message to provide if the function doesn't throw rather than something to validate the thrown error.
Sorry, something went wrong.
There was a problem hiding this comment.
I am not sure I can follow. The situation was only improved in case three arguments are passed to throws. Otherwise the problem continues to exist. So the mitigation is only very tiny as the typical wrong use case is probably assert.throws(fn, "error msg").
I thought a few times about how to improve the two args situation but as far as I see it there is nothing that can be done to improve it. I actually also thought about deprecating using a string as second argument but that would be very inconsistent and weird as well.
Sorry, something went wrong.
There was a problem hiding this comment.
Refining my comment a bit: The current version of the example code (assert.throws(fn, str, str)) is obviously an error. The version above in this PR (assert.throws(fn, str)) is less obviously an error because maybe "missing foo" is not an expected error message but rather the error message we want to provide if the function doesn't throw as expected. It's not clear to me if the best way to clarify is to edit the text preceding the block or if it is to edit missing foo to say something else.
Sorry, something went wrong.
There was a problem hiding this comment.
LGTM with doc comment addressed.
Sorry, something went wrong.
There was a problem hiding this comment.
Agree with @Trott abotu the doc being a little confusing now.
Sorry, something went wrong.
|
I updated the example and tried to be as detailed and precise as possible. |
Sorry, something went wrong.
|
While thinking about this further: is this actually a semver-patch instead of semver-major? Because the use case when a error is now thrown is clearly a mistake and did not work as the user intended. |
Sorry, something went wrong.
There was a problem hiding this comment.
Nit: difficult to spot -> difficult-to-spot
Sorry, something went wrong.
There was a problem hiding this comment.
Should it be as the second instead of as second? That seems more natural to me.
Sorry, something went wrong.
There was a problem hiding this comment.
Hm, for me as second sounds better but I am probably not the best one to ask in this case. Are there any other votes? 😆
Sorry, something went wrong.
There was a problem hiding this comment.
Am I missing something subtle? It looks like line 794 and line 796 are the same?
Sorry, something went wrong.
There was a problem hiding this comment.
The called function is named similar but different. I clarified it now by choosing a different name.
Sorry, something went wrong.
|
@BridgeAR I'm OK with patch for this but would be interested in some other @nodejs/tsc opinions. Technically, anything that introduces a throw in a situation where it previously was not throwing is supposed to be treated as a breaking change, but I'm not sure that really applies in a situation like this where the code that doesn't throw is kinda broken anyway. |
Sorry, something went wrong.
|
Left some nits on the new doc changes, but I really like the direction you went with it. 👍 |
Sorry, something went wrong.
|
I updated it and also added a independent commit to clarify how the RegExp actually works. |
Sorry, something went wrong.
There was a problem hiding this comment.
LGTM
Sorry, something went wrong.
|
I would release this as minor. Mainly to give it a bit more time to bake for LTS. |
Sorry, something went wrong.
Sorry, something went wrong.
There was a problem hiding this comment.
Please void using informal pronouns like you in the docs :-)
Sorry, something went wrong.
There was a problem hiding this comment.
I rephrased that but I am not really happy with what I came up with
Please read the example below carefully if using a string as the second argument gets considered:
and
If it was intended to match for the error message do this instead:
Sorry, something went wrong.
There was a problem hiding this comment.
Few grammar notes
Sorry, something went wrong.
There was a problem hiding this comment.
Sorry, something went wrong.
There was a problem hiding this comment.
Needs a comma after object
Sorry, something went wrong.
There was a problem hiding this comment.
as a second argument
Sorry, something went wrong.
There was a problem hiding this comment.
I would think it should be more like as the second argument since there can only be one
Sorry, something went wrong.
There was a problem hiding this comment.
I would think it should be more like as the second argument since there can only be one
Sorry, something went wrong.
|
I addressed the comments but I am not that happy with all the changes. So it would be nice to get another look at the sentences that contained a you before. |
Sorry, something went wrong.
Sorry, something went wrong.
|
@BridgeAR I think this should be using node-test-pull-request not node-test-commit-light, in order to run the tests on all platforms. node-test-commit-light is usually only meant to be used on documentation only PRs |
Sorry, something went wrong.
|
@maclover7 I intentionally used that as it should only verify that the rebase was fine. assert has no special behavior on any platform and it should always be sufficient to only run linux-one in that case. It takes ages to run a full CI for changes that absolutely behave the same on all platforms and there is no point in doing that out of my perspective. |
Sorry, something went wrong.
|
PTAL |
Sorry, something went wrong.
|
This does not land cleanly on v9.x, would someone be willing to backport? |
Sorry, something went wrong.
Throw a TypeError in case a error message is provided in the second argument and a third argument is present as well. This is clearly a mistake and should not be done. PR-URL: nodejs#17585 Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com> Reviewed-By: Evan Lucas <evanlucas@me.com>
It was not clear why the error name is actually also tested for when using a regular expression. This is now clarified. PR-URL: nodejs#17585 Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com> Reviewed-By: Evan Lucas <evanlucas@me.com>
Throw a TypeError in case a error message is provided in the second argument and a third argument is present as well. This is clearly a mistake and should not be done. Backport-PR-URL: #19230 PR-URL: #17585 Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com> Reviewed-By: Evan Lucas <evanlucas@me.com>
It was not clear why the error name is actually also tested for when using a regular expression. This is now clarified. Backport-PR-URL: #19230 PR-URL: #17585 Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com> Reviewed-By: Evan Lucas <evanlucas@me.com>
Throw a TypeError in case a error message is provided in the second argument and a third argument is present as well. This is clearly a mistake and should not be done. Backport-PR-URL: #19230 PR-URL: #17585 Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com> Reviewed-By: Evan Lucas <evanlucas@me.com>
It was not clear why the error name is actually also tested for when using a regular expression. This is now clarified. Backport-PR-URL: #19230 PR-URL: #17585 Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com> Reviewed-By: Evan Lucas <evanlucas@me.com>
|
Requested backport to 8.x in #19230 |
Sorry, something went wrong.
Throw a TypeError in case a error message is provided in the second argument and a third argument is present as well. This is clearly a mistake and should not be done. PR-URL: nodejs#17585 Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com> Reviewed-By: Evan Lucas <evanlucas@me.com>
Throw a TypeError in case a error message is provided in the second argument and a third argument is present as well. This is clearly a mistake and should not be done. Backport-PR-URL: #23223 PR-URL: #17585 Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com> Reviewed-By: Evan Lucas <evanlucas@me.com>
| Back | FazBrowse Home | New Git URL |
Throw a TypeError in case a error message is provided in the second
argument and a third argument is present as well.
This is clearly a mistake and should not be done.
CI https://ci.nodejs.org/job/node-test-pull-request/12015/
Checklist
Affected core subsystem(s)
assert