Skip to content

Commit f8cd96a

Browse files
Trotttargos
authored andcommitted
doc: simplify "is recommended" language in assert documentation
Replace "X is not recommended" with "Avoid X". Replace "It is recommended not to use X" with "Avoid X". PR-URL: #30558 Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Michaël Zasso <[email protected]> Reviewed-By: Gireesh Punathil <[email protected]> Reviewed-By: Trivikram Kamat <[email protected]>
1 parent ef9dd60 commit f8cd96a

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

doc/api/assert.md

+7-6
Original file line numberDiff line numberDiff line change
@@ -1234,10 +1234,11 @@ assert.throws(
12341234
(err) => {
12351235
assert(err instanceof Error);
12361236
assert(/value/.test(err));
1237-
// Returning anything from validation functions besides `true` is not
1238-
// recommended. Doing so results in the caught error being thrown again.
1239-
// That is usually not the desired outcome. Throw an error about the
1240-
// specific validation that failed instead (as done in this example).
1237+
// Avoid returning anything from validation functions besides `true`.
1238+
// Otherwise, it's not clear what part of the validation failed. Instead,
1239+
// throw an error about the specific validation that failed (as done in this
1240+
// example) and add as much helpful debugging information to that error as
1241+
// possible.
12411242
return true;
12421243
},
12431244
'unexpected error'
@@ -1288,8 +1289,8 @@ assert.throws(throwingFirst, /Second$/);
12881289
// at throwingFirst (repl:2:9)
12891290
```
12901291

1291-
Due to the confusing notation, it is recommended not to use a string as the
1292-
second argument. This might lead to difficult-to-spot errors.
1292+
Due to the confusing error-prone notation, avoid a string as the second
1293+
argument.
12931294

12941295
[`Class`]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes
12951296
[`ERR_INVALID_RETURN_VALUE`]: errors.html#errors_err_invalid_return_value

0 commit comments

Comments
 (0)