From aae9bd5847d4a210bb22cff45a51f74b920f5cf5 Mon Sep 17 00:00:00 2001 From: Mike-7777777 <41225783+Mike-7777777@users.noreply.github.com> Date: Sun, 22 Nov 2026 17:16:40 +0800 Subject: [PATCH] wordy: document the required exception message --- .../practice/wordy/.docs/instructions.append.md | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 exercises/practice/wordy/.docs/instructions.append.md diff --git a/exercises/practice/wordy/.docs/instructions.append.md b/exercises/practice/wordy/.docs/instructions.append.md new file mode 100644 index 000000000..96e475638 --- /dev/null +++ b/exercises/practice/wordy/.docs/instructions.append.md @@ -0,0 +1,15 @@ +# Instructions append + +## Exception messages + +Sometimes it is necessary to [throw an exception](https://docs.oracle.com/javase/tutorial/essential/exceptions/throwing.html). +When you do this, you should always include a **meaningful error message** to indicate what the source of the error is. +This makes your code more readable and helps significantly with debugging. + +This particular exercise requires that you use the [throw keyword](https://docs.oracle.com/javase/tutorial/essential/exceptions/throwing.html) +to "throw" an `IllegalArgumentException` if the question passed to `solve()` contains an unsupported operation, is not a math question, or has invalid syntax. +The tests will only pass if you both `throw` the `exception` and include this exact message with it, which is the same for every case: + +```java +throw new IllegalArgumentException("I'm sorry, I don't understand the question!"); +```