diff options
author | Michaël Zasso <targos@protonmail.com> | 2018-02-27 14:55:32 +0100 |
---|---|---|
committer | Michaël Zasso <targos@protonmail.com> | 2018-03-05 19:51:30 +0100 |
commit | 1e8d110e640c658e4f6ed7540db62d063269ba6c (patch) | |
tree | afe2636b1b190fee00006beaa484fa77d5949770 /lib/readline.js | |
parent | 023f49c5a938ef631260b76876155eaf957084be (diff) | |
download | node-new-1e8d110e640c658e4f6ed7540db62d063269ba6c.tar.gz |
lib: port errors to new system
This is a first batch of updates that touches non-underscored modules in
lib.
PR-URL: https://github.com/nodejs/node/pull/19034
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Diffstat (limited to 'lib/readline.js')
-rw-r--r-- | lib/readline.js | 23 |
1 files changed, 9 insertions, 14 deletions
diff --git a/lib/readline.js b/lib/readline.js index 15933e6930..124fc8111b 100644 --- a/lib/readline.js +++ b/lib/readline.js @@ -27,7 +27,11 @@ 'use strict'; -const errors = require('internal/errors'); +const { + ERR_INVALID_ARG_TYPE, + ERR_INVALID_CURSOR_POS, + ERR_INVALID_OPT_VALUE +} = require('internal/errors').codes; const { debug, inherits } = require('util'); const { Buffer } = require('buffer'); const EventEmitter = require('events'); @@ -95,7 +99,7 @@ function Interface(input, output, completer, terminal) { } if (completer && typeof completer !== 'function') { - throw new errors.TypeError('ERR_INVALID_OPT_VALUE', 'completer', completer); + throw new ERR_INVALID_OPT_VALUE('completer', completer); } if (historySize === undefined) { @@ -105,11 +109,7 @@ function Interface(input, output, completer, terminal) { if (typeof historySize !== 'number' || Number.isNaN(historySize) || historySize < 0) { - throw new errors.RangeError( - 'ERR_INVALID_OPT_VALUE', - 'historySize', - historySize - ); + throw new ERR_INVALID_OPT_VALUE.RangeError('historySize', historySize); } // backwards compat; check the isTTY prop of the output stream @@ -288,12 +288,7 @@ Interface.prototype._onLine = function(line) { Interface.prototype._writeToOutput = function _writeToOutput(stringToWrite) { if (typeof stringToWrite !== 'string') { - throw new errors.TypeError( - 'ERR_INVALID_ARG_TYPE', - 'stringToWrite', - 'string', - stringToWrite - ); + throw new ERR_INVALID_ARG_TYPE('stringToWrite', 'string', stringToWrite); } if (this.output !== null && this.output !== undefined) { @@ -1067,7 +1062,7 @@ function cursorTo(stream, x, y) { return; if (typeof x !== 'number') - throw new errors.Error('ERR_INVALID_CURSOR_POS'); + throw new ERR_INVALID_CURSOR_POS(); if (typeof y !== 'number') { stream.write(CSI`${x + 1}G`); |