Skip to content

Commit 0b42990

Browse files
committed
doc: fix CCM cipher example in MJS
The original example used 'return' to terminate the current control flow, which is valid in CommonJS. When the example was copied and modified to use MJS syntax, the 'return' statement was left in but is not allowed. Refs: nodejs#37594
1 parent 660b1d1 commit 0b42990

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

doc/api/crypto.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5260,8 +5260,7 @@ const receivedPlaintext = decipher.update(ciphertext, null, 'utf8');
52605260
try {
52615261
decipher.final();
52625262
} catch (err) {
5263-
console.error('Authentication failed!');
5264-
return;
5263+
throw new Error('Authentication failed!');
52655264
}
52665265

52675266
console.log(receivedPlaintext);
@@ -5305,8 +5304,7 @@ const receivedPlaintext = decipher.update(ciphertext, null, 'utf8');
53055304
try {
53065305
decipher.final();
53075306
} catch (err) {
5308-
console.error('Authentication failed!');
5309-
return;
5307+
throw new Error('Authentication failed!');
53105308
}
53115309

53125310
console.log(receivedPlaintext);

0 commit comments

Comments
 (0)