summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorSteven <steven@ceriously.com>2017-12-17 14:55:22 -0500
committerJoyee Cheung <joyeec9h3@gmail.com>2017-12-24 01:42:59 +0800
commit8599465d33b16b12da844f115fd10f9af4ad530f (patch)
tree60237fc19b6439b7331c83f261949d0dd185d2af /lib
parentae2bed993884573f88da906d435c992e445c3834 (diff)
downloadandroid-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.js9
1 files changed, 7 insertions, 2 deletions
diff --git a/lib/fs.js b/lib/fs.js
index fe657c3c24..94da3914c3 100644
--- a/lib/fs.js
+++ b/lib/fs.js
@@ -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() {