diff options
author | James M Snell <jasnell@gmail.com> | 2017-10-27 17:20:54 -0700 |
---|---|---|
committer | James M Snell <jasnell@gmail.com> | 2017-11-02 11:58:38 -0700 |
commit | 3d9d84940ae11a026c8f14e1b502794db7538765 (patch) | |
tree | 634619ce40599ea3da38b37398314dfeceecd7cf /lib/tty.js | |
parent | 056b858e57a72c5429d9278bc7b77d1922a2dbe4 (diff) | |
download | android-node-v8-3d9d84940ae11a026c8f14e1b502794db7538765.tar.gz android-node-v8-3d9d84940ae11a026c8f14e1b502794db7538765.tar.bz2 android-node-v8-3d9d84940ae11a026c8f14e1b502794db7538765.zip |
tty: convert to internal/errors using SystemError
PR-URL: https://github.com/nodejs/node/pull/16567
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
Diffstat (limited to 'lib/tty.js')
-rw-r--r-- | lib/tty.js | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/lib/tty.js b/lib/tty.js index cf020f529d..144fc86b8e 100644 --- a/lib/tty.js +++ b/lib/tty.js @@ -40,11 +40,17 @@ function ReadStream(fd, options) { if (fd >> 0 !== fd || fd < 0) throw new errors.RangeError('ERR_INVALID_FD', fd); + const ctx = {}; + const tty = new TTY(fd, true, ctx); + if (ctx.code !== undefined) { + throw new errors.SystemError(ctx); + } + options = util._extend({ highWaterMark: 0, readable: true, writable: false, - handle: new TTY(fd, true) + handle: tty }, options); net.Socket.call(this, options); @@ -69,8 +75,14 @@ function WriteStream(fd) { if (fd >> 0 !== fd || fd < 0) throw new errors.RangeError('ERR_INVALID_FD', fd); + const ctx = {}; + const tty = new TTY(fd, false, ctx); + if (ctx.code !== undefined) { + throw new errors.SystemError(ctx); + } + net.Socket.call(this, { - handle: new TTY(fd, false), + handle: tty, readable: false, writable: true }); |