From 9a23156dcb5f8c2ca8240782298616bc97db77ca Mon Sep 17 00:00:00 2001 From: Ruben Bridgewater Date: Sat, 10 Feb 2018 16:50:20 +0100 Subject: [PATCH 1/2] 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. --- doc/api/assert.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/doc/api/assert.md b/doc/api/assert.md index 5ca1f0830853b8..97bb7d77124be7 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 not recommended 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 all +error messages in your code as expressive as possible. + When `assert.doesNotThrow()` is called, it will immediately call the `block` function. From 697c2e3b8d526f7471de879858f8ffc1674a8b32 Mon Sep 17 00:00:00 2001 From: Ruben Bridgewater Date: Wed, 7 Mar 2018 00:24:35 +0100 Subject: [PATCH 2/2] fixup --- doc/api/assert.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/doc/api/assert.md b/doc/api/assert.md index 97bb7d77124be7..6728a819d3ba9e 100644 --- a/doc/api/assert.md +++ b/doc/api/assert.md @@ -330,10 +330,10 @@ 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 -a comment next to the specific code path that should not throw and keep all -error messages in your code as expressive as possible. +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.