aboutsummaryrefslogtreecommitdiff
path: root/doc
diff options
context:
space:
mode:
authorRuben Bridgewater <ruben@bridgewater.de>2018-02-10 16:50:20 +0100
committerRuben Bridgewater <ruben@bridgewater.de>2018-03-11 02:47:26 +0100
commit8b69d4aca9a89db1e986ce137ff67f4b8bf8803f (patch)
tree3e5a22d59d4e9d764a7eb3a25f6f01f8ec19aed1 /doc
parent4893f70d12691208abf8c668d8347240df561f14 (diff)
downloadandroid-node-v8-8b69d4aca9a89db1e986ce137ff67f4b8bf8803f.tar.gz
android-node-v8-8b69d4aca9a89db1e986ce137ff67f4b8bf8803f.tar.bz2
android-node-v8-8b69d4aca9a89db1e986ce137ff67f4b8bf8803f.zip
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. 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.md5
1 files changed, 5 insertions, 0 deletions
diff --git a/doc/api/assert.md b/doc/api/assert.md
index 5ca1f08308..6728a819d3 100644
--- a/doc/api/assert.md
+++ b/doc/api/assert.md
@@ -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 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.