GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — crypto: improve randomInt out-of-range error message · nodejs/node@3573545

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • lib/internal/crypto
    • random.js
  • test/parallel
    • test-crypto-random.js
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎lib/internal/crypto/random.js‎

Copy file name to clipboardExpand all lines: lib/internal/crypto/random.js
+3-1Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,9 @@ function randomInt(min, max, callback) {
150150
throw new ERR_INVALID_ARG_TYPE('max', 'safe integer', max);
151151
}
152152
if (max <= min) {
153-
throw new ERR_OUT_OF_RANGE('max', `> ${min}`, max);
153+
throw new ERR_OUT_OF_RANGE(
154+
'max', `greater than the value of "min" (${min})`, max
155+
);
154156
}
155157

156158
// First we generate a random int between [0..range)
Collapse file

‎test/parallel/test-crypto-random.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-crypto-random.js
+3-2Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -462,8 +462,9 @@ assert.throws(
462462
assert.throws(() => crypto.randomInt(...arg, common.mustNotCall()), {
463463
code: 'ERR_OUT_OF_RANGE',
464464
name: 'RangeError',
465-
message: 'The value of "max" is out of range. It must be > ' +
466-
`${arg[arg.length - 2] || 0}. Received ${arg[arg.length - 1]}`
465+
message: 'The value of "max" is out of range. It must be greater than ' +
466+
`the value of "min" (${arg[arg.length - 2] || 0}). ` +
467+
`Received ${arg[arg.length - 1]}`
467468
});
468469
}
469470

0 commit comments

Comments
0 (0)
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.