From 680a88316510f51e7a2c74736ed47ee3c399f0a7 Mon Sep 17 00:00:00 2001 From: davidmarkclements Date: Thu, 12 Apr 2018 21:00:24 +0200 Subject: [PATCH] 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. --- lib/internal/errors.js | 4 +--- test/parallel/test-repl-options.js | 14 +++++++++++++- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/lib/internal/errors.js b/lib/internal/errors.js index 99ffb46783b8cb..15bfd5e29dbf88 100644 --- a/lib/internal/errors.js +++ b/lib/internal/errors.js @@ -828,10 +828,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); diff --git a/test/parallel/test-repl-options.js b/test/parallel/test-repl-options.js index 3b373669ed60bb..6bd908aadf935d 100644 --- a/test/parallel/test-repl-options.js +++ b/test/parallel/test-repl-options.js @@ -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, '> ');