From 00ca8488aafe374306bd98030cbe9aff5e309fa4 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 45f31a003844ef..00bdfbc6fdc5a2 100644 --- a/doc/api/crypto.md +++ b/doc/api/crypto.md @@ -5285,8 +5285,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); @@ -5330,8 +5329,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);