From 0b429909b4ff980701c4b34f4698f588a92ff71a 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 1/3] 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 --- 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 57ad8ccf7e675e..8ac725b582ea62 100644 --- a/doc/api/crypto.md +++ b/doc/api/crypto.md @@ -5260,8 +5260,7 @@ const receivedPlaintext = decipher.update(ciphertext, null, 'utf8'); try { decipher.final(); } catch (err) { - console.error('Authentication failed!'); - return; + throw new Error('Authentication failed!'); } console.log(receivedPlaintext); @@ -5305,8 +5304,7 @@ const receivedPlaintext = decipher.update(ciphertext, null, 'utf8'); try { decipher.final(); } catch (err) { - console.error('Authentication failed!'); - return; + throw new Error('Authentication failed!'); } console.log(receivedPlaintext); From ca3a2e9eed0e97a86214cc907eb138c069072cad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tobias=20Nie=C3=9Fen?= Date: Thu, 2 Sep 2021 15:19:32 +0200 Subject: [PATCH 2/3] Update doc/api/crypto.md Co-authored-by: Antoine du Hamel --- doc/api/crypto.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/api/crypto.md b/doc/api/crypto.md index 8ac725b582ea62..affbc160dd6b38 100644 --- a/doc/api/crypto.md +++ b/doc/api/crypto.md @@ -5260,7 +5260,7 @@ const receivedPlaintext = decipher.update(ciphertext, null, 'utf8'); try { decipher.final(); } catch (err) { - throw new Error('Authentication failed!'); + throw new Error('Authentication failed!', { cause: err }); } console.log(receivedPlaintext); From df20f829bb7a865f43e64c9bc483bdc37b2f5fb4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tobias=20Nie=C3=9Fen?= Date: Thu, 2 Sep 2021 15:19:37 +0200 Subject: [PATCH 3/3] Update doc/api/crypto.md Co-authored-by: Antoine du Hamel --- doc/api/crypto.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/api/crypto.md b/doc/api/crypto.md index affbc160dd6b38..4188aa194cbd1a 100644 --- a/doc/api/crypto.md +++ b/doc/api/crypto.md @@ -5304,7 +5304,7 @@ const receivedPlaintext = decipher.update(ciphertext, null, 'utf8'); try { decipher.final(); } catch (err) { - throw new Error('Authentication failed!'); + throw new Error('Authentication failed!', { cause: err }); } console.log(receivedPlaintext);