buffer: improve ERR_BUFFER_OUT_OF_BOUNDS default

This commit changes the default message used by
ERR_BUFFER_OUT_OF_BOUNDS. Previously, the default
message implied that the problematic was always a
write, which is not accurate.

PR-URL: https://github.com/nodejs/node/pull/29098
Fixes: https://github.com/nodejs/node/issues/29097
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Sam Roberts <vieuxtech@gmail.com>
Reviewed-By: Jiawen Geng <technicalcute@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Yongsheng Zhang <zyszys98@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
This commit is contained in:
cjihrig 2019-08-12 17:03:47 -04:00 committed by Rich Trott
parent 427e5348a2
commit a352a7129e
7 changed files with 7 additions and 7 deletions

View File

@ -710,7 +710,7 @@ E('ERR_BUFFER_OUT_OF_BOUNDS',
if (name) {
return `"${name}" is outside of buffer bounds`;
}
return 'Attempt to write outside buffer bounds';
return 'Attempt to access memory outside buffer bounds';
}, RangeError);
E('ERR_BUFFER_TOO_LARGE',
`Cannot create a Buffer larger than 0x${kMaxLength.toString(16)} bytes`,

View File

@ -362,7 +362,7 @@ common.expectsError(() => {
}, {
code: 'ERR_BUFFER_OUT_OF_BOUNDS',
type: RangeError,
message: 'Attempt to write outside buffer bounds'
message: 'Attempt to access memory outside buffer bounds'
});
assert.deepStrictEqual(

View File

@ -60,7 +60,7 @@ const OOR_ERROR =
const OOB_ERROR =
{
name: 'RangeError',
message: 'Attempt to write outside buffer bounds'
message: 'Attempt to access memory outside buffer bounds'
};
// Attempt to overflow buffers, similar to previous bug in array buffers

View File

@ -127,7 +127,7 @@ assert.strictEqual(buffer.readDoubleLE(0), -Infinity);
{
code: 'ERR_BUFFER_OUT_OF_BOUNDS',
name: 'RangeError',
message: 'Attempt to write outside buffer bounds'
message: 'Attempt to access memory outside buffer bounds'
});
[NaN, 1.01].forEach((offset) => {

View File

@ -90,7 +90,7 @@ assert.strictEqual(buffer.readFloatLE(0), -Infinity);
{
code: 'ERR_BUFFER_OUT_OF_BOUNDS',
name: 'RangeError',
message: 'Attempt to write outside buffer bounds'
message: 'Attempt to access memory outside buffer bounds'
});
[NaN, 1.01].forEach((offset) => {

View File

@ -99,7 +99,7 @@ assert.ok(Number.isNaN(buffer.readDoubleLE(8)));
{
code: 'ERR_BUFFER_OUT_OF_BOUNDS',
name: 'RangeError',
message: 'Attempt to write outside buffer bounds'
message: 'Attempt to access memory outside buffer bounds'
});
['', '0', null, {}, [], () => {}, true, false].forEach((off) => {

View File

@ -81,7 +81,7 @@ assert.ok(Number.isNaN(buffer.readFloatLE(4)));
{
code: 'ERR_BUFFER_OUT_OF_BOUNDS',
name: 'RangeError',
message: 'Attempt to write outside buffer bounds'
message: 'Attempt to access memory outside buffer bounds'
});
['', '0', null, {}, [], () => {}, true, false].forEach((off) => {