Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit f8cd96a

Browse filesBrowse 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 <cjihrig@gmail.com> Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
1 parent ef9dd60 commit f8cd96a
Copy full SHA for f8cd96a

File tree

Expand file treeCollapse file tree

1 file changed

+7
-6
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+7
-6
lines changed
Open diff view settings
Collapse file

‎doc/api/assert.md‎

Copy file name to clipboardExpand all lines: doc/api/assert.md
+7-6Lines changed: 7 additions & 6 deletions
  • Display the source diff
  • Display the rich diff
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 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.