From 775048d54c6f190cbc8c0b55c0b53d2ba9d4d028 Mon Sep 17 00:00:00 2001 From: Brian White Date: Sun, 18 Aug 2019 23:24:49 -0400 Subject: [PATCH] buffer: correct concat() error message PR-URL: https://github.com/nodejs/node/pull/29198 Reviewed-By: Colin Ihrig Reviewed-By: James M Snell Reviewed-By: Luigi Pinca Reviewed-By: Ruben Bridgewater --- lib/buffer.js | 2 +- test/parallel/test-buffer-concat.js | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/buffer.js b/lib/buffer.js index 7f33bcab5e164a..7753e3239feeb0 100644 --- a/lib/buffer.js +++ b/lib/buffer.js @@ -525,7 +525,7 @@ Buffer.concat = function concat(list, length) { // TODO(BridgeAR): This should not be of type ERR_INVALID_ARG_TYPE. // Instead, find the proper error code for this. throw new ERR_INVALID_ARG_TYPE( - `list[${i}]`, ['Array', 'Buffer', 'Uint8Array'], list[i]); + `list[${i}]`, ['Buffer', 'Uint8Array'], list[i]); } _copy(buf, buffer, pos); pos += buf.length; diff --git a/test/parallel/test-buffer-concat.js b/test/parallel/test-buffer-concat.js index 7ef5b9cd3591b2..6be3a39fa00a26 100644 --- a/test/parallel/test-buffer-concat.js +++ b/test/parallel/test-buffer-concat.js @@ -59,7 +59,7 @@ assert.strictEqual(flatLongLen.toString(), check); Buffer.concat(value); }, { 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]}` }); }); @@ -68,7 +68,7 @@ assert.throws(() => { Buffer.concat([Buffer.from('hello'), 3]); }, { 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' });