From df6f2ce67314dca7a5e0725dd07b557214dcba9e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Belin?= Date: Mon, 29 Jan 2024 16:36:20 +0100 Subject: [PATCH] Update the documentation --- docs/usage/check_comment.md | 3 ++- docs/usage/submit_ham.md | 3 ++- docs/usage/submit_spam.md | 3 ++- docs/usage/verify_key.md | 3 ++- 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/docs/usage/check_comment.md b/docs/usage/check_comment.md index eb0b21c5..1407d5bb 100644 --- a/docs/usage/check_comment.md +++ b/docs/usage/check_comment.md @@ -63,7 +63,8 @@ try { console.log(result == CheckResult.ham ? "The comment is ham." : "The comment is spam."); } catch (error) { - console.log(`An error occurred: ${error}`); + const message = error instanceof Error ? error.message : String(error); + console.log(`An error occurred: ${message}`); } ``` diff --git a/docs/usage/submit_ham.md b/docs/usage/submit_ham.md index c31f354e..75139bbe 100644 --- a/docs/usage/submit_ham.md +++ b/docs/usage/submit_ham.md @@ -50,6 +50,7 @@ try { console.log("The comment was successfully submitted as ham."); } catch (error) { - console.log(`An error occurred: ${error}`); + const message = error instanceof Error ? error.message : String(error); + console.log(`An error occurred: ${message}`); } ``` diff --git a/docs/usage/submit_spam.md b/docs/usage/submit_spam.md index bc22296a..ff14a51d 100644 --- a/docs/usage/submit_spam.md +++ b/docs/usage/submit_spam.md @@ -52,6 +52,7 @@ try { console.log("The comment was successfully submitted as spam."); } catch (error) { - console.log(`An error occurred: ${error}`); + const message = error instanceof Error ? error.message : String(error); + console.log(`An error occurred: ${message}`); } ``` diff --git a/docs/usage/verify_key.md b/docs/usage/verify_key.md index dfd077ff..85588479 100644 --- a/docs/usage/verify_key.md +++ b/docs/usage/verify_key.md @@ -38,7 +38,8 @@ try { console.log(isValid ? "The API key is valid." : "The API key is invalid."); } catch (error) { - console.log(`An error occurred: ${error}`); + const message = error instanceof Error ? error.message : String(error); + console.log(`An error occurred: ${message}`); } ```