Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions lib/internal/errors.js
Original file line number Diff line number Diff line change
Expand Up @@ -1404,7 +1404,8 @@ E('ERR_INVALID_ARG_TYPE',
// For cases like 'first argument'
msg += `${name} `;
} else {
const type = StringPrototypeIncludes(name, '.') ? 'property' : 'argument';
const type = (StringPrototypeIncludes(name, '.') ||
StringPrototypeIncludes(name, '[')) ? 'property' : 'argument';
msg += `"${name}" ${type} `;
}
msg += 'must be ';
Expand Down Expand Up @@ -1468,7 +1469,8 @@ E('ERR_INVALID_ARG_VALUE', (name, value, reason = 'is invalid') => {
if (inspected.length > 128) {
inspected = `${StringPrototypeSlice(inspected, 0, 128)}...`;
}
const type = StringPrototypeIncludes(name, '.') ? 'property' : 'argument';
const type = (StringPrototypeIncludes(name, '.') ||
StringPrototypeIncludes(name, '[')) ? 'property' : 'argument';
return `The ${type} '${name}' ${reason}. Received ${inspected}`;
}, TypeError, RangeError, HideStackFramesError);
E('ERR_INVALID_ASYNC_ID', 'Invalid %s value: %s', RangeError);
Expand Down
4 changes: 2 additions & 2 deletions test/parallel/test-buffer-concat.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ assert.strictEqual(flatLongLen.toString(), check);
Buffer.concat(value);
}, {
code: 'ERR_INVALID_ARG_TYPE',
message: 'The "list[0]" argument must be an instance of Buffer ' +
message: 'The "list[0]" property must be an instance of Buffer ' +
`or Uint8Array.${common.invalidArgTypeHelper(value[0])}`
});
});
Expand All @@ -68,7 +68,7 @@ assert.throws(() => {
Buffer.concat([Buffer.from('hello'), 3]);
}, {
code: 'ERR_INVALID_ARG_TYPE',
message: 'The "list[1]" argument must be an instance of Buffer ' +
message: 'The "list[1]" property must be an instance of Buffer ' +
'or Uint8Array. Received type number (3)'
});

Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-diff.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ describe('diff', () => {
const expected = ['1', '2'];

assert.throws(() => diff(actual, expected), {
message: 'The "actual[1]" argument must be of type string. Received an instance of Object'
message: 'The "actual[1]" property must be of type string. Received an instance of Object'
});
});

Expand Down
4 changes: 2 additions & 2 deletions test/parallel/test-dns-setservers-type-check.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ const promiseResolver = new dns.promises.Resolver();
const errObj = {
code: 'ERR_INVALID_ARG_TYPE',
name: 'TypeError',
message: 'The "servers[0]" argument must be of type string.' +
message: 'The "servers[0]" property must be of type string.' +
common.invalidArgTypeHelper(val[0])
};
assert.throws(
Expand Down Expand Up @@ -110,7 +110,7 @@ const promiseResolver = new dns.promises.Resolver();
const errObj = {
code: 'ERR_INVALID_ARG_TYPE',
name: 'TypeError',
message: 'The "servers[0]" argument must be of type string.' +
message: 'The "servers[0]" property must be of type string.' +
common.invalidArgTypeHelper(val[0])
};
assert.throws(() => {
Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-process-setgroups.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ assert.throws(
{
code: 'ERR_INVALID_ARG_TYPE',
name: 'TypeError',
message: 'The "groups[0]" argument must be ' +
message: 'The "groups[0]" property must be ' +
'one of type number or string.' +
common.invalidArgTypeHelper(val)
}
Expand Down
4 changes: 2 additions & 2 deletions test/parallel/test-tls-set-default-ca-certificates-error.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,14 @@ for (const invalid of [null, undefined, 42, {}, true]) {
// Test input validation - should throw when passed an array with invalid elements
assert.throws(() => tls.setDefaultCACertificates([invalid]), {
code: 'ERR_INVALID_ARG_TYPE',
message: /The "certs\[0\]" argument must be of type string or an instance of ArrayBufferView/
message: /The "certs\[0\]" property must be of type string or an instance of ArrayBufferView/
});
// Verify that default certificates remain unchanged after error.
assertEqualCerts(tls.getCACertificates('default'), defaultCerts);

assert.throws(() => tls.setDefaultCACertificates([fixtureCert, invalid]), {
code: 'ERR_INVALID_ARG_TYPE',
message: /The "certs\[1\]" argument must be of type string or an instance of ArrayBufferView/
message: /The "certs\[1\]" property must be of type string or an instance of ArrayBufferView/
});
// Verify that default certificates remain unchanged after error.
assertEqualCerts(tls.getCACertificates('default'), defaultCerts);
Expand Down
Loading