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}`); } ```