File tree 3 files changed +16
-7
lines changed
3 files changed +16
-7
lines changed Original file line number Diff line number Diff line change @@ -114,6 +114,7 @@ E('ERR_ARG_NOT_ITERABLE', '%s must be iterable');
114
114
E ( 'ERR_ASSERTION' , ( msg ) => msg ) ;
115
115
E ( 'ERR_INVALID_ARG_TYPE' , invalidArgType ) ;
116
116
E ( 'ERR_INVALID_CALLBACK' , 'callback must be a function' ) ;
117
+ E ( 'ERR_INVALID_FD' , ( fd ) => `"fd" must be a positive integer: ${ fd } ` ) ;
117
118
E ( 'ERR_INVALID_FILE_URL_HOST' , 'File URL host %s' ) ;
118
119
E ( 'ERR_INVALID_FILE_URL_PATH' , 'File URL path %s' ) ;
119
120
E ( 'ERR_INVALID_HANDLE_TYPE' , 'This handle type cannot be sent' ) ;
Original file line number Diff line number Diff line change @@ -27,7 +27,7 @@ const TTY = process.binding('tty_wrap').TTY;
27
27
const isTTY = process . binding ( 'tty_wrap' ) . isTTY ;
28
28
const inherits = util . inherits ;
29
29
const errnoException = util . _errnoException ;
30
-
30
+ const errors = require ( 'internal/errors' ) ;
31
31
32
32
exports . isatty = function ( fd ) {
33
33
return isTTY ( fd ) ;
@@ -38,7 +38,7 @@ function ReadStream(fd, options) {
38
38
if ( ! ( this instanceof ReadStream ) )
39
39
return new ReadStream ( fd , options ) ;
40
40
if ( fd >> 0 !== fd || fd < 0 )
41
- throw new RangeError ( 'fd must be positive integer: ' + fd ) ;
41
+ throw new errors . RangeError ( 'ERR_INVALID_FD' , fd ) ;
42
42
43
43
options = util . _extend ( {
44
44
highWaterMark : 0 ,
@@ -67,7 +67,7 @@ function WriteStream(fd) {
67
67
if ( ! ( this instanceof WriteStream ) )
68
68
return new WriteStream ( fd ) ;
69
69
if ( fd >> 0 !== fd || fd < 0 )
70
- throw new RangeError ( 'fd must be positive integer: ' + fd ) ;
70
+ throw new errors . RangeError ( 'ERR_INVALID_FD' , fd ) ;
71
71
72
72
net . Socket . call ( this , {
73
73
handle : new TTY ( fd , false ) ,
Original file line number Diff line number Diff line change 1
1
'use strict' ;
2
-
3
2
const common = require ( '../common' ) ;
4
3
const assert = require ( 'assert' ) ;
5
4
const fs = require ( 'fs' ) ;
6
5
const tty = require ( 'tty' ) ;
7
6
8
-
9
7
assert . throws ( ( ) => {
10
8
new tty . WriteStream ( - 1 ) ;
11
- } , / f d m u s t b e p o s i t i v e i n t e g e r : / ) ;
9
+ } , common . expectsError ( {
10
+ code : 'ERR_INVALID_FD' ,
11
+ type : RangeError ,
12
+ message : '"fd" must be a positive integer: -1'
13
+ } )
14
+ ) ;
12
15
13
16
const err_regex = common . isWindows ?
14
17
/ ^ E r r o r : E B A D F : b a d f i l e d e s c r i p t o r , u v _ t t y _ i n i t $ / :
@@ -24,7 +27,12 @@ assert.throws(() => {
24
27
25
28
assert . throws ( ( ) => {
26
29
new tty . ReadStream ( - 1 ) ;
27
- } , / f d m u s t b e p o s i t i v e i n t e g e r : / ) ;
30
+ } , common . expectsError ( {
31
+ code : 'ERR_INVALID_FD' ,
32
+ type : RangeError ,
33
+ message : '"fd" must be a positive integer: -1'
34
+ } )
35
+ ) ;
28
36
29
37
assert . throws ( ( ) => {
30
38
let fd = 2 ;
You can’t perform that action at this time.
0 commit comments