2727
2828'use strict' ;
2929
30+ const errors = require ( 'internal/errors' ) ;
3031const { debug, inherits } = require ( 'util' ) ;
3132const Buffer = require ( 'buffer' ) . Buffer ;
3233const EventEmitter = require ( 'events' ) ;
@@ -95,7 +96,7 @@ function Interface(input, output, completer, terminal) {
9596 }
9697
9798 if ( completer && typeof completer !== 'function' ) {
98- throw new TypeError ( 'Argument " completer" must be a function' ) ;
99+ throw new errors . TypeError ( 'ERR_INVALID_OPT_VALUE' , ' completer' , completer ) ;
99100 }
100101
101102 if ( historySize === undefined ) {
@@ -105,7 +106,11 @@ function Interface(input, output, completer, terminal) {
105106 if ( typeof historySize !== 'number' ||
106107 isNaN ( historySize ) ||
107108 historySize < 0 ) {
108- throw new TypeError ( 'Argument "historySize" must be a positive number' ) ;
109+ throw new errors . RangeError (
110+ 'ERR_INVALID_OPT_VALUE' ,
111+ 'historySize' ,
112+ historySize
113+ ) ;
109114 }
110115
111116 // backwards compat; check the isTTY prop of the output stream
@@ -281,7 +286,12 @@ Interface.prototype._onLine = function(line) {
281286
282287Interface . prototype . _writeToOutput = function _writeToOutput ( stringToWrite ) {
283288 if ( typeof stringToWrite !== 'string' )
284- throw new TypeError ( '"stringToWrite" argument must be a string' ) ;
289+ throw new errors . TypeError (
290+ 'ERR_INVALID_ARG_TYPE' ,
291+ 'stringToWrite' ,
292+ 'string' ,
293+ stringToWrite
294+ ) ;
285295
286296 if ( this . output !== null && this . output !== undefined )
287297 this . output . write ( stringToWrite ) ;
@@ -1053,7 +1063,7 @@ function cursorTo(stream, x, y) {
10531063 return ;
10541064
10551065 if ( typeof x !== 'number' )
1056- throw new Error ( 'Can\'t set cursor row without also setting it\'s column ' ) ;
1066+ throw new errors . Error ( 'ERR_INVALID_CURSOR_POS ' ) ;
10571067
10581068 if ( typeof y !== 'number' ) {
10591069 stream . write ( CSI `${ x + 1 } G` ) ;
0 commit comments