From 8826cc985acc5588185a1af84260bbaaf7f7c19c 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. PR-URL: https://github.com/nodejs/node/pull/19984 Reviewed-By: James M Snell Reviewed-By: Ruben Bridgewater Reviewed-By: Luigi Pinca Reviewed-By: Trivikram Kamat --- 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 401051bab1e..c2a0f086201 100644 --- a/lib/internal/errors.js +++ b/lib/internal/errors.js @@ -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); diff --git a/test/parallel/test-repl-options.js b/test/parallel/test-repl-options.js index 3b373669ed6..6bd908aadf9 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, '> ');