Skip to content

Commit

Permalink
errors: alter and test ERR_INVALID_REPL_EVAL_CONFIG
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
davidmarkclements authored and jasnell committed Apr 16, 2018
1 parent b806b04 commit 83a8261
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
4 changes: 1 addition & 3 deletions lib/internal/errors.js
Original file line number Diff line number Diff line change
Expand Up @@ -903,10 +903,8 @@ E('ERR_INVALID_PERFORMANCE_MARK',

// This should probably be a `TypeError`.
E('ERR_INVALID_PROTOCOL', 'Protocol "%s" not supported. Expected "%s"', Error);

// This should probably be a `TypeError`.
E('ERR_INVALID_REPL_EVAL_CONFIG',
'Cannot specify both "breakEvalOnSigint" and "eval" for REPL', Error);
'Cannot specify both "breakEvalOnSigint" and "eval" for REPL', TypeError);
E('ERR_INVALID_SYNC_FORK_INPUT',
'Asynchronous forks do not support Buffer, Uint8Array or string input: %s',
TypeError);
Expand Down
14 changes: 13 additions & 1 deletion test/parallel/test-repl-options.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,19 @@ assert.strictEqual(r2.rli.input, r2.inputStream);
assert.strictEqual(r2.rli.output, r2.outputStream);
assert.strictEqual(r2.rli.terminal, false);

// Verify that defaults are used when no arguments are provided
// 3, breakEvalOnSigint and eval supplied together should cause a throw
const r3 = () => repl.start({
breakEvalOnSigint: true,
eval: true
});

common.expectsError(r3, {
code: 'ERR_INVALID_REPL_EVAL_CONFIG',
type: TypeError,
message: 'Cannot specify both "breakEvalOnSigint" and "eval" for REPL'
});

// 4, Verify that defaults are used when no arguments are provided
const r4 = repl.start();

assert.strictEqual(r4._prompt, '> ');
Expand Down

0 comments on commit 83a8261

Please sign in to comment.