27
27
28
28
'use strict' ;
29
29
30
+ const errors = require ( 'internal/errors' ) ;
30
31
const { debug, inherits } = require ( 'util' ) ;
31
32
const Buffer = require ( 'buffer' ) . Buffer ;
32
33
const EventEmitter = require ( 'events' ) ;
@@ -95,7 +96,7 @@ function Interface(input, output, completer, terminal) {
95
96
}
96
97
97
98
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 ) ;
99
100
}
100
101
101
102
if ( historySize === undefined ) {
@@ -105,7 +106,11 @@ function Interface(input, output, completer, terminal) {
105
106
if ( typeof historySize !== 'number' ||
106
107
isNaN ( historySize ) ||
107
108
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
+ ) ;
109
114
}
110
115
111
116
// backwards compat; check the isTTY prop of the output stream
@@ -281,7 +286,12 @@ Interface.prototype._onLine = function(line) {
281
286
282
287
Interface . prototype . _writeToOutput = function _writeToOutput ( stringToWrite ) {
283
288
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
+ ) ;
285
295
286
296
if ( this . output !== null && this . output !== undefined )
287
297
this . output . write ( stringToWrite ) ;
@@ -1053,7 +1063,7 @@ function cursorTo(stream, x, y) {
1053
1063
return ;
1054
1064
1055
1065
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 ' ) ;
1057
1067
1058
1068
if ( typeof y !== 'number' ) {
1059
1069
stream . write ( CSI `${ x + 1 } G` ) ;
0 commit comments