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 try/catch statement to handle exceptions #654

Open lorenzholzbauer opened 2 months ago

lorenzholzbauer commented 2 months ago

Is there an existing proposal for this?

This feature does not exist in the latest version

Proposal

Add try/catch statement support, which can handle exceptions and execute specific clauses based on error pattern matching. It also includes a finally clause, which gets executed regardless of what happened before.

var x: num;
try {
  x = fetch("http://localhost") force as num;
} catch (e: InvalidCastException) {
  x = 2;
} finally {
  print(x as str):
}

Exact behaviour / changes you want