Skip to content

Commit

Permalink
stream: improve the error message of ERR_INVALID_ARG_TYPE
Browse files Browse the repository at this point in the history
The `expected` argument of `ERR_INVALID_ARG_TYPE` can be an
array, which is better than a single string.

PR-URL: #17145
Reviewed-By: Anatoli Papirovski <apapirovski@mac.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
  • Loading branch information
starkwang authored and MylesBorins committed Dec 12, 2017
1 parent 2fccf84 commit b36c726
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/_stream_readable.js
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ function chunkInvalid(state, chunk) {
chunk !== undefined &&
!state.objectMode) {
er = new errors.TypeError('ERR_INVALID_ARG_TYPE',
'chunk', 'string/Buffer/Uint8Array');
'chunk', ['string', 'Buffer', 'Uint8Array']);
}
return er;
}
Expand Down
3 changes: 2 additions & 1 deletion lib/_stream_writable.js
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,8 @@ function validChunk(stream, state, chunk, cb) {
} else if (typeof chunk !== 'string' &&
chunk !== undefined &&
!state.objectMode) {
er = new errors.TypeError('ERR_INVALID_ARG_TYPE', 'chunk', 'string/buffer');
er = new errors.TypeError('ERR_INVALID_ARG_TYPE', 'chunk',
['string', 'Buffer']);
}
if (er) {
stream.emit('error', er);
Expand Down

0 comments on commit b36c726

Please sign in to comment.