buffer: correct concat() error message

PR-URL: https://github.com/nodejs/node/pull/29198
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
This commit is contained in:
Brian White 2019-08-18 23:24:49 -04:00 committed by Rich Trott
parent 6afd1a3dc1
commit 775048d54c
2 changed files with 3 additions and 3 deletions

View File

@ -525,7 +525,7 @@ Buffer.concat = function concat(list, length) {
// TODO(BridgeAR): This should not be of type ERR_INVALID_ARG_TYPE. // TODO(BridgeAR): This should not be of type ERR_INVALID_ARG_TYPE.
// Instead, find the proper error code for this. // Instead, find the proper error code for this.
throw new ERR_INVALID_ARG_TYPE( throw new ERR_INVALID_ARG_TYPE(
`list[${i}]`, ['Array', 'Buffer', 'Uint8Array'], list[i]); `list[${i}]`, ['Buffer', 'Uint8Array'], list[i]);
} }
_copy(buf, buffer, pos); _copy(buf, buffer, pos);
pos += buf.length; pos += buf.length;

View File

@ -59,7 +59,7 @@ assert.strictEqual(flatLongLen.toString(), check);
Buffer.concat(value); Buffer.concat(value);
}, { }, {
code: 'ERR_INVALID_ARG_TYPE', code: 'ERR_INVALID_ARG_TYPE',
message: 'The "list[0]" argument must be one of type Array, Buffer, ' + message: 'The "list[0]" argument must be one of type Buffer ' +
`or Uint8Array. Received type ${typeof value[0]}` `or Uint8Array. Received type ${typeof value[0]}`
}); });
}); });
@ -68,7 +68,7 @@ assert.throws(() => {
Buffer.concat([Buffer.from('hello'), 3]); Buffer.concat([Buffer.from('hello'), 3]);
}, { }, {
code: 'ERR_INVALID_ARG_TYPE', code: 'ERR_INVALID_ARG_TYPE',
message: 'The "list[1]" argument must be one of type Array, Buffer, ' + message: 'The "list[1]" argument must be one of type Buffer ' +
'or Uint8Array. Received type number' 'or Uint8Array. Received type number'
}); });