Skip to content

Commit b36c726

Browse files
starkwangMylesBorins
authored andcommitted
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. PR-URL: #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]>
1 parent 2fccf84 commit b36c726

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

lib/_stream_readable.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ function chunkInvalid(state, chunk) {
285285
chunk !== undefined &&
286286
!state.objectMode) {
287287
er = new errors.TypeError('ERR_INVALID_ARG_TYPE',
288-
'chunk', 'string/Buffer/Uint8Array');
288+
'chunk', ['string', 'Buffer', 'Uint8Array']);
289289
}
290290
return er;
291291
}

lib/_stream_writable.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,8 @@ function validChunk(stream, state, chunk, cb) {
252252
} else if (typeof chunk !== 'string' &&
253253
chunk !== undefined &&
254254
!state.objectMode) {
255-
er = new errors.TypeError('ERR_INVALID_ARG_TYPE', 'chunk', 'string/buffer');
255+
er = new errors.TypeError('ERR_INVALID_ARG_TYPE', 'chunk',
256+
['string', 'Buffer']);
256257
}
257258
if (er) {
258259
stream.emit('error', er);

0 commit comments

Comments
 (0)