Skip to content

Commit

Permalink
lib: change ERR_INVALID_ARG_VALUE error message
Browse files Browse the repository at this point in the history
  • Loading branch information
lundibundi committed Sep 11, 2020
1 parent b1831fe commit 3ec5b48
Show file tree
Hide file tree
Showing 42 changed files with 81 additions and 81 deletions.
2 changes: 1 addition & 1 deletion lib/internal/errors.js
Expand Up @@ -1083,7 +1083,7 @@ E('ERR_INVALID_ARG_VALUE', (name, value, reason = 'is invalid') => {
inspected = `${inspected.slice(0, 128)}...`;
}
const type = name.includes('.') ? 'property' : 'argument';
return `The ${type} '${name}' ${reason}. Received ${inspected}`;
return `The '${name}' ${type} ${reason}. Received ${inspected}`;
}, TypeError, RangeError);
E('ERR_INVALID_ASYNC_ID', 'Invalid %s value: %s', RangeError);
E('ERR_INVALID_BUFFER_SIZE',
Expand Down
2 changes: 1 addition & 1 deletion test/es-module/test-esm-dns-promises.mjs
Expand Up @@ -10,5 +10,5 @@ assert.throws(() => {
}, {
code: 'ERR_INVALID_ARG_VALUE',
name: 'TypeError',
message: `The argument 'address' is invalid. Received '${invalidAddress}'`
message: `The 'address' argument is invalid. Received '${invalidAddress}'`
});
2 changes: 1 addition & 1 deletion test/internet/test-dns-promises-resolve.js
Expand Up @@ -12,7 +12,7 @@ const dnsPromises = require('dns').promises;
{
code: 'ERR_INVALID_ARG_VALUE',
name: 'TypeError',
message: `The argument 'rrtype' is invalid. Received '${rrtype}'`
message: `The 'rrtype' is invalid. Received '${rrtype}' argument`
}
);
}
Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-assert.js
Expand Up @@ -1082,7 +1082,7 @@ assert.throws(
assert.throws(
() => assert.throws(() => { throw new Error(); }, {}),
{
message: "The argument 'error' may not be an empty object. Received {}",
message: "The 'error' argument may not be an empty object. Received {}",
code: 'ERR_INVALID_ARG_VALUE'
}
);
Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-buffer-no-negative-allocation.js
Expand Up @@ -7,7 +7,7 @@ const { SlowBuffer } = require('buffer');
const msg = {
code: 'ERR_INVALID_ARG_VALUE',
name: 'RangeError',
message: /^The argument 'size' is invalid\. Received [^"]*$/
message: /^The 'size' argument is invalid\. Received [^"]*$/
};

// Test that negative Buffer length inputs throw errors.
Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-buffer-over-max-length.js
Expand Up @@ -9,7 +9,7 @@ const kMaxLength = buffer.kMaxLength;
const bufferMaxSizeMsg = {
code: 'ERR_INVALID_ARG_VALUE',
name: 'RangeError',
message: /^The argument 'size' is invalid\. Received [^"]*$/
message: /^The 'size' argument is invalid\. Received [^"]*$/
};

assert.throws(() => Buffer((-1 >>> 0) + 1), bufferMaxSizeMsg);
Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-buffer-slow.js
Expand Up @@ -54,7 +54,7 @@ assert.throws(() => SlowBuffer(true), bufferInvalidTypeMsg);
const bufferMaxSizeMsg = {
code: 'ERR_INVALID_ARG_VALUE',
name: 'RangeError',
message: /^The argument 'size' is invalid\. Received [^"]*$/
message: /^The 'size' argument is invalid\. Received [^"]*$/
};
assert.throws(() => SlowBuffer(NaN), bufferMaxSizeMsg);
assert.throws(() => SlowBuffer(Infinity), bufferMaxSizeMsg);
Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-buffer-tostring-rangeerror.js
Expand Up @@ -12,7 +12,7 @@ const len = 1422561062959;
const message = {
code: 'ERR_INVALID_ARG_VALUE',
name: 'RangeError',
message: /^The argument 'size' is invalid\. Received [^"]*$/
message: /^The 'size' argument is invalid\. Received [^"]*$/
};
assert.throws(() => Buffer(len).toString('utf8'), message);
assert.throws(() => SlowBuffer(len).toString('utf8'), message);
Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-c-ares.js
Expand Up @@ -70,7 +70,7 @@ dns.lookup('::1', common.mustCall((error, result, addressType) => {
const err = {
code: 'ERR_INVALID_ARG_VALUE',
name: 'TypeError',
message: `The argument 'rrtype' is invalid. Received '${val}'`,
message: `The 'rrtype' argument is invalid. Received '${val}'`,
};

assert.throws(
Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-child-process-advanced-serialization.js
Expand Up @@ -11,7 +11,7 @@ if (process.argv[2] !== 'child') {
child_process.spawn(process.execPath, [], { serialization: value });
}, {
code: 'ERR_INVALID_ARG_VALUE',
message: "The property 'options.serialization' " +
message: "The 'options.serialization' property " +
"must be one of: undefined, 'json', 'advanced'. " +
`Received ${inspect(value)}`
});
Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-console-tty-colors.js
Expand Up @@ -67,7 +67,7 @@ check(false, false, false);
});
},
{
message: `The argument 'colorMode' is invalid. Received ${received}`,
message: `The 'colorMode' argument is invalid. Received ${received}`,
code: 'ERR_INVALID_ARG_VALUE'
}
);
Expand Down
10 changes: 5 additions & 5 deletions test/parallel/test-crypto-authenticated.js
Expand Up @@ -330,7 +330,7 @@ for (const test of TEST_CASES) {
}, {
name: 'TypeError',
code: 'ERR_INVALID_ARG_VALUE',
message: "The property 'options.authTagLength' is invalid. " +
message: "The 'options.authTagLength' property is invalid. " +
`Received ${inspect(authTagLength)}`
});

Expand All @@ -344,7 +344,7 @@ for (const test of TEST_CASES) {
}, {
name: 'TypeError',
code: 'ERR_INVALID_ARG_VALUE',
message: "The property 'options.authTagLength' is invalid. " +
message: "The 'options.authTagLength' property is invalid. " +
`Received ${inspect(authTagLength)}`
});

Expand All @@ -354,7 +354,7 @@ for (const test of TEST_CASES) {
}, {
name: 'TypeError',
code: 'ERR_INVALID_ARG_VALUE',
message: "The property 'options.authTagLength' is invalid. " +
message: "The 'options.authTagLength' property is invalid. " +
`Received ${inspect(authTagLength)}`
});

Expand All @@ -363,7 +363,7 @@ for (const test of TEST_CASES) {
}, {
name: 'TypeError',
code: 'ERR_INVALID_ARG_VALUE',
message: "The property 'options.authTagLength' is invalid. " +
message: "The 'options.authTagLength' property is invalid. " +
`Received ${inspect(authTagLength)}`
});
}
Expand Down Expand Up @@ -454,7 +454,7 @@ for (const test of TEST_CASES) {
}, {
name: 'TypeError',
code: 'ERR_INVALID_ARG_VALUE',
message: "The property 'options.plaintextLength' is invalid. " +
message: "The 'options.plaintextLength' property is invalid. " +
`Received ${inspect(plaintextLength)}`
});
}
Expand Down
4 changes: 2 additions & 2 deletions test/parallel/test-crypto-dh-stateless.js
Expand Up @@ -92,13 +92,13 @@ const bobPublicKey = crypto.createPublicKey({
assert.throws(() => crypto.diffieHellman({ privateKey: alicePrivateKey }), {
name: 'TypeError',
code: 'ERR_INVALID_ARG_VALUE',
message: "The property 'options.publicKey' is invalid. Received undefined"
message: "The 'options.publicKey' property is invalid. Received undefined"
});

assert.throws(() => crypto.diffieHellman({ publicKey: alicePublicKey }), {
name: 'TypeError',
code: 'ERR_INVALID_ARG_VALUE',
message: "The property 'options.privateKey' is invalid. Received undefined"
message: "The 'options.privateKey' property is invalid. Received undefined"
});

const privateKey = Buffer.from(
Expand Down
6 changes: 3 additions & 3 deletions test/parallel/test-crypto-key-objects.js
Expand Up @@ -49,7 +49,7 @@ const privateDsa = fixtures.readKey('dsa_private_encrypted_1025.pem',
assert.throws(() => new KeyObject(TYPE), {
name: 'TypeError',
code: 'ERR_INVALID_ARG_VALUE',
message: `The argument 'type' is invalid. Received '${TYPE}'`
message: `The 'type' argument is invalid. Received '${TYPE}'`
});
}

Expand Down Expand Up @@ -224,7 +224,7 @@ const privateDsa = fixtures.readKey('dsa_private_encrypted_1025.pem',
createPrivateKey({ key: Buffer.alloc(0), format: 'der', type: 'spki' });
}, {
code: 'ERR_INVALID_ARG_VALUE',
message: "The property 'options.type' is invalid. Received 'spki'"
message: "The 'options.type' property is invalid. Received 'spki'"
});

// Unlike SPKI, PKCS#1 is a valid encoding for private keys (and public keys),
Expand Down Expand Up @@ -472,6 +472,6 @@ const privateDsa = fixtures.readKey('dsa_private_encrypted_1025.pem',
}, {
name: 'TypeError',
code: 'ERR_INVALID_ARG_VALUE',
message: "The property 'options.cipher' is invalid. Received undefined"
message: "The 'options.cipher' property is invalid. Received undefined"
});
}
38 changes: 19 additions & 19 deletions test/parallel/test-crypto-keygen.js
Expand Up @@ -559,7 +559,7 @@ const sec1EncExp = (cipher) => getRegExpForPEM('EC PRIVATE KEY', cipher);
}), {
name: 'TypeError',
code: 'ERR_INVALID_ARG_VALUE',
message: "The property 'options.paramEncoding' is invalid. " +
message: "The 'options.paramEncoding' property is invalid. " +
"Received 'otherEncoding'"
});
}
Expand Down Expand Up @@ -606,7 +606,7 @@ const sec1EncExp = (cipher) => getRegExpForPEM('EC PRIVATE KEY', cipher);
assert.throws(() => generateKeyPairSync('rsa2', {}), {
name: 'TypeError',
code: 'ERR_INVALID_ARG_VALUE',
message: "The argument 'type' must be a supported key type. Received 'rsa2'"
message: "The 'type' argument must be a supported key type. Received 'rsa2'"
});
}

Expand Down Expand Up @@ -686,7 +686,7 @@ const sec1EncExp = (cipher) => getRegExpForPEM('EC PRIVATE KEY', cipher);
}), {
name: 'TypeError',
code: 'ERR_INVALID_ARG_VALUE',
message: "The property 'options.publicKeyEncoding' is invalid. " +
message: "The 'options.publicKeyEncoding' property is invalid. " +
`Received ${inspect(enc)}`
});
}
Expand All @@ -706,7 +706,7 @@ const sec1EncExp = (cipher) => getRegExpForPEM('EC PRIVATE KEY', cipher);
}), {
name: 'TypeError',
code: 'ERR_INVALID_ARG_VALUE',
message: "The property 'options.publicKeyEncoding.type' is invalid. " +
message: "The 'options.publicKeyEncoding.type' property is invalid. " +
`Received ${inspect(type)}`
});
}
Expand All @@ -726,7 +726,7 @@ const sec1EncExp = (cipher) => getRegExpForPEM('EC PRIVATE KEY', cipher);
}), {
name: 'TypeError',
code: 'ERR_INVALID_ARG_VALUE',
message: "The property 'options.publicKeyEncoding.format' is invalid. " +
message: "The 'options.publicKeyEncoding.format' property is invalid. " +
`Received ${inspect(format)}`
});
}
Expand All @@ -743,7 +743,7 @@ const sec1EncExp = (cipher) => getRegExpForPEM('EC PRIVATE KEY', cipher);
}), {
name: 'TypeError',
code: 'ERR_INVALID_ARG_VALUE',
message: "The property 'options.privateKeyEncoding' is invalid. " +
message: "The 'options.privateKeyEncoding' property is invalid. " +
`Received ${inspect(enc)}`
});
}
Expand All @@ -763,7 +763,7 @@ const sec1EncExp = (cipher) => getRegExpForPEM('EC PRIVATE KEY', cipher);
}), {
name: 'TypeError',
code: 'ERR_INVALID_ARG_VALUE',
message: "The property 'options.privateKeyEncoding.type' is invalid. " +
message: "The 'options.privateKeyEncoding.type' property is invalid. " +
`Received ${inspect(type)}`
});
}
Expand All @@ -783,7 +783,7 @@ const sec1EncExp = (cipher) => getRegExpForPEM('EC PRIVATE KEY', cipher);
}), {
name: 'TypeError',
code: 'ERR_INVALID_ARG_VALUE',
message: "The property 'options.privateKeyEncoding.format' is invalid. " +
message: "The 'options.privateKeyEncoding.format' property is invalid. " +
`Received ${inspect(format)}`
});
}
Expand All @@ -804,7 +804,7 @@ const sec1EncExp = (cipher) => getRegExpForPEM('EC PRIVATE KEY', cipher);
}), {
name: 'TypeError',
code: 'ERR_INVALID_ARG_VALUE',
message: "The property 'options.privateKeyEncoding.cipher' is invalid. " +
message: "The 'options.privateKeyEncoding.cipher' property is invalid. " +
`Received ${inspect(cipher)}`
});
}
Expand Down Expand Up @@ -845,7 +845,7 @@ const sec1EncExp = (cipher) => getRegExpForPEM('EC PRIVATE KEY', cipher);
}), {
name: 'TypeError',
code: 'ERR_INVALID_ARG_VALUE',
message: "The property 'options.privateKeyEncoding.passphrase' " +
message: "The 'options.privateKeyEncoding.passphrase' property " +
`is invalid. Received ${inspect(passphrase)}`
});
}
Expand All @@ -872,7 +872,7 @@ const sec1EncExp = (cipher) => getRegExpForPEM('EC PRIVATE KEY', cipher);
}), {
name: 'TypeError',
code: 'ERR_INVALID_ARG_VALUE',
message: "The property 'options.modulusLength' is invalid. " +
message: "The 'options.modulusLength' property is invalid. " +
`Received ${inspect(modulusLength)}`
});
}
Expand All @@ -885,7 +885,7 @@ const sec1EncExp = (cipher) => getRegExpForPEM('EC PRIVATE KEY', cipher);
}), {
name: 'TypeError',
code: 'ERR_INVALID_ARG_VALUE',
message: "The property 'options.publicExponent' is invalid. " +
message: "The 'options.publicExponent' property is invalid. " +
`Received ${inspect(publicExponent)}`
});
}
Expand All @@ -900,7 +900,7 @@ const sec1EncExp = (cipher) => getRegExpForPEM('EC PRIVATE KEY', cipher);
}), {
name: 'TypeError',
code: 'ERR_INVALID_ARG_VALUE',
message: "The property 'options.modulusLength' is invalid. " +
message: "The 'options.modulusLength' property is invalid. " +
`Received ${inspect(modulusLength)}`
});
}
Expand All @@ -913,7 +913,7 @@ const sec1EncExp = (cipher) => getRegExpForPEM('EC PRIVATE KEY', cipher);
}), {
name: 'TypeError',
code: 'ERR_INVALID_ARG_VALUE',
message: "The property 'options.divisorLength' is invalid. " +
message: "The 'options.divisorLength' property is invalid. " +
`Received ${inspect(divisorLength)}`
});
}
Expand Down Expand Up @@ -944,7 +944,7 @@ const sec1EncExp = (cipher) => getRegExpForPEM('EC PRIVATE KEY', cipher);
}, {
name: 'TypeError',
code: 'ERR_INVALID_ARG_VALUE',
message: "The property 'options.namedCurve' is invalid. " +
message: "The 'options.namedCurve' property is invalid. " +
`Received ${inspect(namedCurve)}`
});
}
Expand Down Expand Up @@ -1066,7 +1066,7 @@ const sec1EncExp = (cipher) => getRegExpForPEM('EC PRIVATE KEY', cipher);
}, {
name: 'TypeError',
code: 'ERR_INVALID_ARG_VALUE',
message: "The property 'options.publicKeyEncoding.type' is invalid. " +
message: "The 'options.publicKeyEncoding.type' property is invalid. " +
`Received ${inspect(type)}`
});
}
Expand All @@ -1081,7 +1081,7 @@ const sec1EncExp = (cipher) => getRegExpForPEM('EC PRIVATE KEY', cipher);
}, {
name: 'TypeError',
code: 'ERR_INVALID_ARG_VALUE',
message: "The property 'options.hash' is invalid. " +
message: "The 'options.hash' property is invalid. " +
`Received ${inspect(hashValue)}`
});
}
Expand All @@ -1097,7 +1097,7 @@ const sec1EncExp = (cipher) => getRegExpForPEM('EC PRIVATE KEY', cipher);
}, {
name: 'TypeError',
code: 'ERR_INVALID_ARG_VALUE',
message: "The property 'options.privateKeyEncoding.type' is invalid. " +
message: "The 'options.privateKeyEncoding.type' property is invalid. " +
`Received ${inspect(type)}`
});
}
Expand Down Expand Up @@ -1197,7 +1197,7 @@ const sec1EncExp = (cipher) => getRegExpForPEM('EC PRIVATE KEY', cipher);
{
name: 'TypeError',
code: 'ERR_INVALID_ARG_VALUE',
message: "The property 'options.mgf1Hash' is invalid. " +
message: "The 'options.mgf1Hash' property is invalid. " +
`Received ${inspect(mgf1Hash)}`

}
Expand Down
4 changes: 2 additions & 2 deletions test/parallel/test-crypto-sign-verify.js
Expand Up @@ -76,7 +76,7 @@ assert.throws(
{
code: 'ERR_INVALID_ARG_VALUE',
name: 'TypeError',
message: "The property 'options.padding' is invalid. Received null",
message: "The 'options.padding' property is invalid. Received null",
});

assert.throws(
Expand All @@ -87,7 +87,7 @@ assert.throws(
{
code: 'ERR_INVALID_ARG_VALUE',
name: 'TypeError',
message: "The property 'options.saltLength' is invalid. Received null",
message: "The 'options.saltLength' property is invalid. Received null",
});

// Test signing and verifying
Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-crypto.js
Expand Up @@ -164,7 +164,7 @@ testImmutability(crypto.getCurves);
const encodingError = {
code: 'ERR_INVALID_ARG_VALUE',
name: 'TypeError',
message: "The argument 'encoding' is invalid for data of length 1." +
message: "The 'encoding' argument is invalid for data of length 1." +
" Received 'hex'",
};

Expand Down
4 changes: 2 additions & 2 deletions test/parallel/test-dns-lookup.js
Expand Up @@ -54,7 +54,7 @@ assert.throws(() => {
const err = {
code: 'ERR_INVALID_ARG_VALUE',
name: 'TypeError',
message: "The argument 'hints' is invalid. Received 100"
message: "The 'hints' argument is invalid. Received 100"
};
const options = {
hints: 100,
Expand All @@ -72,7 +72,7 @@ assert.throws(() => {
const err = {
code: 'ERR_INVALID_ARG_VALUE',
name: 'TypeError',
message: "The argument 'family' must be one of: 0, 4, 6. Received 20"
message: "The 'family' argument must be one of: 0, 4, 6. Received 20"
};
const options = {
hints: 0,
Expand Down

0 comments on commit 3ec5b48

Please sign in to comment.