diff options
author | Steven <steven@ceriously.com> | 2017-12-17 14:55:22 -0500 |
---|---|---|
committer | Joyee Cheung <joyeec9h3@gmail.com> | 2017-12-24 01:42:59 +0800 |
commit | 8599465d33b16b12da844f115fd10f9af4ad530f (patch) | |
tree | 60237fc19b6439b7331c83f261949d0dd185d2af /lib | |
parent | ae2bed993884573f88da906d435c992e445c3834 (diff) | |
download | android-node-v8-8599465d33b16b12da844f115fd10f9af4ad530f.tar.gz android-node-v8-8599465d33b16b12da844f115fd10f9af4ad530f.tar.bz2 android-node-v8-8599465d33b16b12da844f115fd10f9af4ad530f.zip |
fs: migrate errors to internal/errors
Throw ERR_INVALID_ARG_TYPE when validating arguments passed to
WriteStream.prototype._write.
Refs: https://github.com/nodejs/node/issues/17709
PR-URL: https://github.com/nodejs/node/pull/17719
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/fs.js | 9 |
1 files changed, 7 insertions, 2 deletions
@@ -2554,8 +2554,13 @@ WriteStream.prototype.open = function() { WriteStream.prototype._write = function(data, encoding, cb) { - if (!(data instanceof Buffer)) - return this.emit('error', new Error('Invalid data')); + if (!(data instanceof Buffer)) { + const err = new errors.TypeError('ERR_INVALID_ARG_TYPE', + 'data', + 'Buffer', + data); + return this.emit('error', err); + } if (typeof this.fd !== 'number') { return this.once('open', function() { |