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: https://github.com/nodejs/node/pull/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>
This commit is contained in:
parent
8f2c366bb2
commit
0a948b903d
@ -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;
|
||||
}
|
||||
|
@ -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);
|
||||
|
Loading…
x
Reference in New Issue
Block a user