Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
stream: improve the error message of ERR_INVALID_ARG_TYPE
The `expected` argument of `ERR_INVALID_ARG_TYPE` can be an
array, which is better than a single string.
  • Loading branch information
starkwang committed Nov 20, 2017
commit c84b2012c2a646d9fac708ed4fe251234dae841e
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