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

doc: add warning to assert.doesNotThrow() #18699

Closed
wants to merge 2 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions doc/api/assert.md
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,11 @@ changes:
Asserts that the function `block` does not throw an error. See
[`assert.throws()`][] for more details.

Please note: Using `assert.doesNotThrow()` is not recommended because there is
no benefit by catching an error and then rethrowing it. Instead, consider adding
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: by -> to

Copy link
Member

@ChALkeR ChALkeR Mar 5, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/recommended/actually useful/

Given that we are not deprecating it and that there is no direct harm, I don't see a reason to recommend avoiding it. Comment vs assert.doesNotThrow is pure stylistic.

A note that it doesn't do anything useful and could be replaced with a comment seems better fit, imo.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can do both. Say that it is not useful and therefore not recommended to use.

a comment next to the specific code path that should not throw and keep all
error messages in your code as expressive as possible.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: your :-(

Perhaps

Instead, consider adding a comment next to the specific code path that should
not throw and keep add error messages as expressive as possible.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jasnell There's an error in your proposed text. I think the word add should be deleted?


When `assert.doesNotThrow()` is called, it will immediately call the `block`
function.

Expand Down