Skip to content

Commit 83a8261

Browse files
davidmarkclementsjasnell
authored andcommitted
errors: alter and test ERR_INVALID_REPL_EVAL_CONFIG
changes the base instance for ERR_INVALID_REPL_EVAL_CONFIG from Error to TypeError as a more accurate representation of the error and adds a unit test for the repl options that trigger this error. PR-URL: #19984 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
1 parent b806b04 commit 83a8261

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

lib/internal/errors.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -903,10 +903,8 @@ E('ERR_INVALID_PERFORMANCE_MARK',
903903

904904
// This should probably be a `TypeError`.
905905
E('ERR_INVALID_PROTOCOL', 'Protocol "%s" not supported. Expected "%s"', Error);
906-
907-
// This should probably be a `TypeError`.
908906
E('ERR_INVALID_REPL_EVAL_CONFIG',
909-
'Cannot specify both "breakEvalOnSigint" and "eval" for REPL', Error);
907+
'Cannot specify both "breakEvalOnSigint" and "eval" for REPL', TypeError);
910908
E('ERR_INVALID_SYNC_FORK_INPUT',
911909
'Asynchronous forks do not support Buffer, Uint8Array or string input: %s',
912910
TypeError);

test/parallel/test-repl-options.js

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,19 @@ assert.strictEqual(r2.rli.input, r2.inputStream);
8989
assert.strictEqual(r2.rli.output, r2.outputStream);
9090
assert.strictEqual(r2.rli.terminal, false);
9191

92-
// Verify that defaults are used when no arguments are provided
92+
// 3, breakEvalOnSigint and eval supplied together should cause a throw
93+
const r3 = () => repl.start({
94+
breakEvalOnSigint: true,
95+
eval: true
96+
});
97+
98+
common.expectsError(r3, {
99+
code: 'ERR_INVALID_REPL_EVAL_CONFIG',
100+
type: TypeError,
101+
message: 'Cannot specify both "breakEvalOnSigint" and "eval" for REPL'
102+
});
103+
104+
// 4, Verify that defaults are used when no arguments are provided
93105
const r4 = repl.start();
94106

95107
assert.strictEqual(r4._prompt, '> ');

0 commit comments

Comments
 (0)