File tree Expand file tree Collapse file tree 3 files changed +16
-7
lines changed
Expand file tree Collapse file tree 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');
114114E ( 'ERR_ASSERTION' , ( msg ) => msg ) ;
115115E ( 'ERR_INVALID_ARG_TYPE' , invalidArgType ) ;
116116E ( 'ERR_INVALID_CALLBACK' , 'callback must be a function' ) ;
117+ E ( 'ERR_INVALID_FD' , ( fd ) => `"fd" must be a positive integer: ${ fd } ` ) ;
117118E ( 'ERR_INVALID_FILE_URL_HOST' , 'File URL host %s' ) ;
118119E ( 'ERR_INVALID_FILE_URL_PATH' , 'File URL path %s' ) ;
119120E ( '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;
2727const isTTY = process . binding ( 'tty_wrap' ) . isTTY ;
2828const inherits = util . inherits ;
2929const errnoException = util . _errnoException ;
30-
30+ const errors = require ( 'internal/errors' ) ;
3131
3232exports . isatty = function ( fd ) {
3333 return isTTY ( fd ) ;
@@ -38,7 +38,7 @@ function ReadStream(fd, options) {
3838 if ( ! ( this instanceof ReadStream ) )
3939 return new ReadStream ( fd , options ) ;
4040 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 ) ;
4242
4343 options = util . _extend ( {
4444 highWaterMark : 0 ,
@@ -67,7 +67,7 @@ function WriteStream(fd) {
6767 if ( ! ( this instanceof WriteStream ) )
6868 return new WriteStream ( fd ) ;
6969 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 ) ;
7171
7272 net . Socket . call ( this , {
7373 handle : new TTY ( fd , false ) ,
Original file line number Diff line number Diff line change 11'use strict' ;
2-
32const common = require ( '../common' ) ;
43const assert = require ( 'assert' ) ;
54const fs = require ( 'fs' ) ;
65const tty = require ( 'tty' ) ;
76
8-
97assert . throws ( ( ) => {
108 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+ ) ;
1215
1316const err_regex = common . isWindows ?
1417 / ^ 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(() => {
2427
2528assert . throws ( ( ) => {
2629 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+ ) ;
2836
2937assert . throws ( ( ) => {
3038 let fd = 2 ;
You can’t perform that action at this time.
0 commit comments