Skip to content

Commit d32363f

Browse files
JungMinubrendanashworth
authored andcommitted
doc: fix outdated 'try/catch' statement in sync
Fixes description about crypto.randomBytes. Fixes: #3081 PR-URL: #3087 Reviewed-By: Ben Noordhuis <[email protected]> Reviewed-By: Brendan Ashworth <[email protected]> Reviewed-By: Sakthipriyan Vairamani <[email protected]>
1 parent c273944 commit d32363f

File tree

1 file changed

+2
-7
lines changed

1 file changed

+2
-7
lines changed

doc/api/crypto.markdown

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -651,13 +651,8 @@ Generates cryptographically strong pseudo-random data. Usage:
651651
});
652652

653653
// sync
654-
try {
655-
var buf = crypto.randomBytes(256);
656-
console.log('Have %d bytes of random data: %s', buf.length, buf);
657-
} catch (ex) {
658-
// handle error
659-
// most likely, entropy sources are drained
660-
}
654+
const buf = crypto.randomBytes(256);
655+
console.log('Have %d bytes of random data: %s', buf.length, buf);
661656

662657
NOTE: This will block if there is insufficient entropy, although it should
663658
normally never take longer than a few milliseconds. The only time when this

0 commit comments

Comments
 (0)