diff --git a/lib/internal/crypto/random.js b/lib/internal/crypto/random.js index 5f7f7efbf5b7c3..99d4a2bd89f8dd 100644 --- a/lib/internal/crypto/random.js +++ b/lib/internal/crypto/random.js @@ -150,7 +150,9 @@ function randomInt(min, max, callback) { throw new ERR_INVALID_ARG_TYPE('max', 'safe integer', max); } if (max <= min) { - throw new ERR_OUT_OF_RANGE('max', `> ${min}`, max); + throw new ERR_OUT_OF_RANGE( + 'max', `greater than the value of "min" (${min})`, max + ); } // First we generate a random int between [0..range) diff --git a/test/parallel/test-crypto-random.js b/test/parallel/test-crypto-random.js index b3f14013e59a33..8864b179871137 100644 --- a/test/parallel/test-crypto-random.js +++ b/test/parallel/test-crypto-random.js @@ -462,8 +462,9 @@ assert.throws( assert.throws(() => crypto.randomInt(...arg, common.mustNotCall()), { code: 'ERR_OUT_OF_RANGE', name: 'RangeError', - message: 'The value of "max" is out of range. It must be > ' + - `${arg[arg.length - 2] || 0}. Received ${arg[arg.length - 1]}` + message: 'The value of "max" is out of range. It must be greater than ' + + `the value of "min" (${arg[arg.length - 2] || 0}). ` + + `Received ${arg[arg.length - 1]}` }); }