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

assert: validate the block return type #19886

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
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
Prev Previous commit
fixup: address comments
  • Loading branch information
BridgeAR committed Apr 19, 2018
commit 74efc47121dbc15baa917ff0889c96fa93fbb0ab
11 changes: 4 additions & 7 deletions doc/api/assert.md
Original file line number Diff line number Diff line change
Expand Up @@ -389,11 +389,8 @@ the promise is not rejected.
If `block` is a function and it throws an error synchronously,
`assert.doesNotReject()` will return a rejected Promise with that error. If the
function does not return a promise, `assert.doesNotReject()` will return a
rejected Promise with an [`ERR_INVALID_RETURN_VALUE`][] error. In both cases
without checking the error handler.

If `block` is a function and it does not return a promise, an
[`ERR_INVALID_RETURN_VALUE`][] error is going to be rejected.
rejected Promise with an [`ERR_INVALID_RETURN_VALUE`][] error. In both cases the
error handler is skipped.

Please note: Using `assert.doesNotReject()` is actually not useful because there
is little benefit by catching a rejection and then rejecting it again. Instead,
Expand Down Expand Up @@ -936,8 +933,8 @@ the promise is rejected.
If `block` is a function and it throws an error synchronously,
`assert.rejects()` will return a rejected Promise with that error. If the
function does not return a promise, `assert.rejects()` will return a rejected
Promise with an [`ERR_INVALID_RETURN_VALUE`][] error. In both cases without
checking the error handler.
Promise with an [`ERR_INVALID_RETURN_VALUE`][] error. In both cases the error
handler is skipped.

Besides the async nature to await the completion behaves identically to
[`assert.throws()`][].
Expand Down
2 changes: 1 addition & 1 deletion doc/api/errors.md
Original file line number Diff line number Diff line change
Expand Up @@ -1176,7 +1176,7 @@ is not supported.
<a id="ERR_INVALID_RETURN_VALUE"></a>
### ERR_INVALID_RETURN_VALUE

Thrown in case a function option does not return a expected value on execution.
Thrown in case a function option does not return an expected value on execution.
For example when a function is expected to return a promise.

<a id="ERR_INVALID_SYNC_FORK_INPUT"></a>
Expand Down