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: nodejs#17145
Reviewed-By: Anatoli Papirovski <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Rich Trott <[email protected]>
Reviewed-By: Joyee Cheung <[email protected]>
  • Loading branch information
starkwang authored and jasnell committed Nov 22, 2017
1 parent 8f2c366 commit 0a948b9
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 0a948b9

Please sign in to comment.