Kipper-Lang / Kipper

The Kipper programming language for Browsers and Node.js 🦊✨ Made at HTL Leonding & JKU Linz
https://kipper-lang.org
GNU General Public License v3.0
26 stars 4 forks source link

[Feature] Implement `throw` keyword to raise errors inside any code block #687

Open Luna-Klatzer opened 1 month ago

Luna-Klatzer commented 1 month ago

Is there an existing proposal for this?

This feature does not exist in the latest version

Proposal

Implement throw keyword which should allow throwing any object of type Error.

For example:

throw new Error("An unexpected Error occurred");

The thrown error should then be catchable using the try/except statement as mentioned in #654:

try {
  ...
  throw new Error();
} except (e: Error) {
  print(f"Something happened! Cause: {e}");
}

Exact behaviour / changes you want