diff options
author | Scott McKenzie <slammayjammay@gmail.com> | 2017-02-14 19:58:49 -0800 |
---|---|---|
committer | James M Snell <jasnell@gmail.com> | 2017-06-13 08:44:22 -0700 |
commit | 7f3f72c19b6a0b23394e32a52c1c34b9d59028a7 (patch) | |
tree | b6324f5175ed80bea3899b9a2fdcbe1ba88c5eeb /lib/readline.js | |
parent | 224dbb12332db99702be64f4e43b3b0d1e8dea58 (diff) | |
download | node-new-7f3f72c19b6a0b23394e32a52c1c34b9d59028a7.tar.gz |
errors, readline: migrate to use internal/errors.js
PR-URL: https://github.com/nodejs/node/pull/11390
Ref: https://github.com/nodejs/node/issues/11273
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Diffstat (limited to 'lib/readline.js')
-rw-r--r-- | lib/readline.js | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/lib/readline.js b/lib/readline.js index 60864f40af..adf2d5f067 100644 --- a/lib/readline.js +++ b/lib/readline.js @@ -27,6 +27,7 @@ 'use strict'; +const errors = require('internal/errors'); const { debug, inherits } = require('util'); const Buffer = require('buffer').Buffer; const EventEmitter = require('events'); @@ -95,7 +96,7 @@ function Interface(input, output, completer, terminal) { } if (completer && typeof completer !== 'function') { - throw new TypeError('Argument "completer" must be a function'); + throw new errors.TypeError('ERR_INVALID_OPT_VALUE', 'completer', completer); } if (historySize === undefined) { @@ -105,7 +106,11 @@ function Interface(input, output, completer, terminal) { if (typeof historySize !== 'number' || isNaN(historySize) || historySize < 0) { - throw new TypeError('Argument "historySize" must be a positive number'); + throw new errors.RangeError( + 'ERR_INVALID_OPT_VALUE', + 'historySize', + historySize + ); } // backwards compat; check the isTTY prop of the output stream @@ -281,7 +286,12 @@ Interface.prototype._onLine = function(line) { Interface.prototype._writeToOutput = function _writeToOutput(stringToWrite) { if (typeof stringToWrite !== 'string') - throw new TypeError('"stringToWrite" argument must be a string'); + throw new errors.TypeError( + 'ERR_INVALID_ARG_TYPE', + 'stringToWrite', + 'string', + stringToWrite + ); if (this.output !== null && this.output !== undefined) this.output.write(stringToWrite); @@ -1053,7 +1063,7 @@ function cursorTo(stream, x, y) { return; if (typeof x !== 'number') - throw new Error('Can\'t set cursor row without also setting it\'s column'); + throw new errors.Error('ERR_INVALID_CURSOR_POS'); if (typeof y !== 'number') { stream.write(CSI`${x + 1}G`); |