diff options
author | Ruben Bridgewater <ruben@bridgewater.de> | 2018-02-10 18:50:20 +0300 |
---|---|---|
committer | Myles Borins <mylesborins@google.com> | 2018-09-06 19:40:52 +0300 |
commit | cae60ca57afd095dca82f095d5322846518d089f (patch) | |
tree | 7fe8b4f9ac932bfe76f4fbfea82ad6f76cfae345 /doc | |
parent | e6131c2687838f15fba660d1f03bfbc33bd8a345 (diff) |
doc: add warning to assert.doesNotThrow()
Using `assert.doesNotThrow()` has no benefit over adding a comment
next to some code that should not throw. Therefore it is from now
on discouraged to use it.
Backport-PR-URL: https://github.com/nodejs/node/pull/22380
PR-URL: https://github.com/nodejs/node/pull/18699
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com>
Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com>
Reviewed-By: Michaƫl Zasso <targos@protonmail.com>
Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
Diffstat (limited to 'doc')
-rw-r--r-- | doc/api/assert.md | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/doc/api/assert.md b/doc/api/assert.md index a859408a8be..3478adbfaf2 100644 --- a/doc/api/assert.md +++ b/doc/api/assert.md @@ -191,6 +191,11 @@ changes: Asserts that the function `block` does not throw an error. See [`assert.throws()`][] for more details. +Please note: Using `assert.doesNotThrow()` is actually not useful because there +is no benefit by catching an error and then rethrowing it. Instead, consider +adding a comment next to the specific code path that should not throw and keep +error messages as expressive as possible. + When `assert.doesNotThrow()` is called, it will immediately call the `block` function. |