diff --git a/lib/internal/crypto/random.js b/lib/internal/crypto/random.js index 99d4a2bd89f8dd..9e0500ea3a67bb 100644 --- a/lib/internal/crypto/random.js +++ b/lib/internal/crypto/random.js @@ -144,10 +144,10 @@ function randomInt(min, max, callback) { throw new ERR_INVALID_CALLBACK(callback); } if (!NumberIsSafeInteger(min)) { - throw new ERR_INVALID_ARG_TYPE('min', 'safe integer', min); + throw new ERR_INVALID_ARG_TYPE('min', 'a safe integer', min); } if (!NumberIsSafeInteger(max)) { - throw new ERR_INVALID_ARG_TYPE('max', 'safe integer', max); + throw new ERR_INVALID_ARG_TYPE('max', 'a safe integer', max); } if (max <= min) { throw new ERR_OUT_OF_RANGE( diff --git a/test/parallel/test-crypto-random.js b/test/parallel/test-crypto-random.js index 8864b179871137..e079bc9de2c7d9 100644 --- a/test/parallel/test-crypto-random.js +++ b/test/parallel/test-crypto-random.js @@ -394,13 +394,13 @@ assert.throws( const invalidMinError = { code: 'ERR_INVALID_ARG_TYPE', name: 'TypeError', - message: 'The "min" argument must be safe integer.' + + message: 'The "min" argument must be a safe integer.' + `${common.invalidArgTypeHelper(i)}`, }; const invalidMaxError = { code: 'ERR_INVALID_ARG_TYPE', name: 'TypeError', - message: 'The "max" argument must be safe integer.' + + message: 'The "max" argument must be a safe integer.' + `${common.invalidArgTypeHelper(i)}`, }; @@ -441,7 +441,7 @@ assert.throws( { code: 'ERR_INVALID_ARG_TYPE', name: 'TypeError', - message: 'The "min" argument must be safe integer.' + + message: 'The "min" argument must be a safe integer.' + `${common.invalidArgTypeHelper(minInt - 1)}`, } ); @@ -451,7 +451,7 @@ assert.throws( { code: 'ERR_INVALID_ARG_TYPE', name: 'TypeError', - message: 'The "max" argument must be safe integer.' + + message: 'The "max" argument must be a safe integer.' + `${common.invalidArgTypeHelper(maxInt + 1)}`, } );