From 6d399e11e9489e3f5ed434c35cbf8dc567728d22 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tobias=20Nie=C3=9Fen?= Date: Tue, 31 Aug 2021 01:01:48 +0200 Subject: [PATCH] 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: https://github.com/nodejs/node/pull/37594 PR-URL: https://github.com/nodejs/node/pull/39949 Reviewed-By: James M Snell Reviewed-By: Antoine du Hamel --- doc/api/crypto.md | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/doc/api/crypto.md b/doc/api/crypto.md index db917d7eb81113..a095ece29a9ace 100644 --- a/doc/api/crypto.md +++ b/doc/api/crypto.md @@ -5283,8 +5283,7 @@ const receivedPlaintext = decipher.update(ciphertext, null, 'utf8'); try { decipher.final(); } catch (err) { - console.error('Authentication failed!'); - return; + throw new Error('Authentication failed!', { cause: err }); } console.log(receivedPlaintext); @@ -5328,8 +5327,7 @@ const receivedPlaintext = decipher.update(ciphertext, null, 'utf8'); try { decipher.final(); } catch (err) { - console.error('Authentication failed!'); - return; + throw new Error('Authentication failed!', { cause: err }); } console.log(receivedPlaintext);