-
Notifications
You must be signed in to change notification settings - Fork 3
Description
📝 Summary
W++ is quirky and chaotic by design — but error messages shouldn’t be. Right now, if you write incorrect W++ code (like referencing an undefined variable or calling a function wrong), the interpreter throws raw C# exceptions, like:
System.Collections.Generic.KeyNotFoundException: The given key was not present in the dictionary.
This is unhelpful for users who don’t know or care that the interpreter is written in C#. Let’s fix that!
🎯 What needs to be done
-
Identify common exception sources in
Interpreter.csand related files (e.g., undefined variable access, wrong number of function args, invalid member access). -
Wrap those sections with more user-friendly error handling, like:
if (!variables.ContainsKey(name))
{
throw new WppRuntimeException($"Variable '{name}' is not defined.");
}
-
(Optional) Create a custom exception class like
WppRuntimeExceptionthat pretty-prints errors in a consistent and readable way (e.g., with line number if available). -
Make sure the CLI catches and displays these nicely.
💡 Examples of improvements
| Before | After |
|---|---|
| KeyNotFoundException | W++ Error: Variable 'foo' is not defined. |
| ArgumentOutOfRangeException | W++ Error: Index 10 out of range for list of length 3. |
| NullReferenceException | W++ Error: Attempted to access a property on null. |
✅ Why this issue is good for beginners
-
It’s isolated and doesn't require deep knowledge of the interpreter internals.
-
You’ll learn how the W++ interpreter evaluates code.
-
You’ll improve the experience of every single user. ❤️
🧪 How to test it
You can write a .wpp file that does something wrong, like:
print(unknownVar)
Then run:
ingot run hello.wpp
Before your fix, it’ll throw a nasty C# stack trace. After your fix, it should show something friendly like:
W++ Error: Variable 'unknownVar' is not defined.