Skip to content

Commit 6d399e1

Browse files
tniessenBethGriggs
authored andcommittedSep 21, 2021
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: #37594 PR-URL: #39949 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
1 parent 9f3a015 commit 6d399e1

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed
 

‎doc/api/crypto.md

+2-4
Original file line numberDiff line numberDiff line change
@@ -5283,8 +5283,7 @@ const receivedPlaintext = decipher.update(ciphertext, null, 'utf8');
52835283
try {
52845284
decipher.final();
52855285
} catch (err) {
5286-
console.error('Authentication failed!');
5287-
return;
5286+
throw new Error('Authentication failed!', { cause: err });
52885287
}
52895288

52905289
console.log(receivedPlaintext);
@@ -5328,8 +5327,7 @@ const receivedPlaintext = decipher.update(ciphertext, null, 'utf8');
53285327
try {
53295328
decipher.final();
53305329
} catch (err) {
5331-
console.error('Authentication failed!');
5332-
return;
5330+
throw new Error('Authentication failed!', { cause: err });
53335331
}
53345332

53355333
console.log(receivedPlaintext);

0 commit comments

Comments
 (0)
Please sign in to comment.