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 b546a2b

Browse filesBrowse files
lundibundiTrott
authored andcommitted
lib: handle one of args case in ERR_MISSING_ARGS
This makes ERR_MISSING_ARGS handle nested arrays in argument names as one-of case and will print them as '"arg1" or "arg2" or "arg3"'. Example: ```js throw new ERR_MISSING_ARGS(['a', 'b', 'c']); // will result in message: // The "a" or "b" or "c" argument must be specified ``` PR-URL: #34022 Fixes: #33930 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Zeyu Yang <himself65@outlook.com>
1 parent 7816e5f commit b546a2b
Copy full SHA for b546a2b

File tree

Expand file treeCollapse file tree

1 file changed

+4
-1
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+4
-1
lines changed
Open diff view settings
Collapse file

‎lib/internal/errors.js‎

Copy file name to clipboardExpand all lines: lib/internal/errors.js
+4-1Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1253,7 +1253,10 @@ E('ERR_MISSING_ARGS',
12531253
assert(args.length > 0, 'At least one arg needs to be specified');
12541254
let msg = 'The ';
12551255
const len = args.length;
1256-
args = args.map((a) => `"${a}"`);
1256+
const wrap = (a) => `"${a}"`;
1257+
args = args.map(
1258+
(a) => (ArrayIsArray(a) ? a.map(wrap).join(' or ') : wrap(a))
1259+
);
12571260
switch (len) {
12581261
case 1:
12591262
msg += `${args[0]} argument`;

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.