errors, repl: migrate to use internal/errors.js
* Use existing errors where suitable * Assign code to a REPL specific error * Include documentation for the new error code PR-URL: https://github.com/nodejs/node/pull/11347 Ref: https://github.com/nodejs/node/issues/11273 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Tobias Nießen <tniessen@tnie.de> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
This commit is contained in:
parent
37fdfce93e
commit
aff8d358fa
@ -632,6 +632,12 @@ communication channel to a child process. See [`child.send()`] and
|
|||||||
Used generically to identify when an invalid or unexpected value has been
|
Used generically to identify when an invalid or unexpected value has been
|
||||||
passed in an options object.
|
passed in an options object.
|
||||||
|
|
||||||
|
<a id="ERR_INVALID_REPL_EVAL_CONFIG"></a>
|
||||||
|
### ERR_INVALID_REPL_EVAL_CONFIG
|
||||||
|
|
||||||
|
Used when both `breakEvalOnSigint` and `eval` options are set
|
||||||
|
in the REPL config, which is not supported.
|
||||||
|
|
||||||
<a id="ERR_INVALID_SYNC_FORK_INPUT"></a>
|
<a id="ERR_INVALID_SYNC_FORK_INPUT"></a>
|
||||||
### ERR_INVALID_SYNC_FORK_INPUT
|
### ERR_INVALID_SYNC_FORK_INPUT
|
||||||
|
|
||||||
|
@ -134,6 +134,8 @@ E('ERR_INVALID_OPT_VALUE',
|
|||||||
(name, value) => {
|
(name, value) => {
|
||||||
return `The value "${String(value)}" is invalid for option "${name}"`;
|
return `The value "${String(value)}" is invalid for option "${name}"`;
|
||||||
});
|
});
|
||||||
|
E('ERR_INVALID_REPL_EVAL_CONFIG',
|
||||||
|
'Cannot specify both "breakEvalOnSigint" and "eval" for REPL');
|
||||||
E('ERR_INVALID_SYNC_FORK_INPUT',
|
E('ERR_INVALID_SYNC_FORK_INPUT',
|
||||||
(value) => {
|
(value) => {
|
||||||
return 'Asynchronous forks do not support Buffer, Uint8Array or string' +
|
return 'Asynchronous forks do not support Buffer, Uint8Array or string' +
|
||||||
|
@ -56,6 +56,7 @@ const Console = require('console').Console;
|
|||||||
const Module = require('module');
|
const Module = require('module');
|
||||||
const domain = require('domain');
|
const domain = require('domain');
|
||||||
const debug = util.debuglog('repl');
|
const debug = util.debuglog('repl');
|
||||||
|
const errors = require('internal/errors');
|
||||||
|
|
||||||
const parentModule = module;
|
const parentModule = module;
|
||||||
const replMap = new WeakMap();
|
const replMap = new WeakMap();
|
||||||
@ -138,7 +139,7 @@ function REPLServer(prompt,
|
|||||||
if (breakEvalOnSigint && eval_) {
|
if (breakEvalOnSigint && eval_) {
|
||||||
// Allowing this would not reflect user expectations.
|
// Allowing this would not reflect user expectations.
|
||||||
// breakEvalOnSigint affects only the behaviour of the default eval().
|
// breakEvalOnSigint affects only the behaviour of the default eval().
|
||||||
throw new Error('Cannot specify both breakEvalOnSigint and eval for REPL');
|
throw new errors.Error('ERR_INVALID_REPL_EVAL_CONFIG');
|
||||||
}
|
}
|
||||||
|
|
||||||
var self = this;
|
var self = this;
|
||||||
@ -1022,7 +1023,8 @@ REPLServer.prototype.defineCommand = function(keyword, cmd) {
|
|||||||
if (typeof cmd === 'function') {
|
if (typeof cmd === 'function') {
|
||||||
cmd = {action: cmd};
|
cmd = {action: cmd};
|
||||||
} else if (typeof cmd.action !== 'function') {
|
} else if (typeof cmd.action !== 'function') {
|
||||||
throw new Error('Bad argument, "action" command must be a function');
|
throw new errors.TypeError('ERR_INVALID_ARG_TYPE',
|
||||||
|
'action', 'function', cmd.action);
|
||||||
}
|
}
|
||||||
this.commands[keyword] = cmd;
|
this.commands[keyword] = cmd;
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user