Skip to content

Commit 4bc6f79

Browse files
tniessenBethGriggs
authored andcommitted
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 b102e07 commit 4bc6f79

1 file changed

Lines changed: 2 additions & 4 deletions

File tree

doc/api/crypto.md

Lines changed: 2 additions & 4 deletions
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)