katsaii / catspeak-lang

A cross-platform modding language for GameMaker games.
https://www.katsaii.com/catspeak-lang/
MIT License
81 stars 4 forks source link

Implement `catch` expression #80

Open katsaii opened 10 months ago

katsaii commented 10 months ago

What is your feature request?

Implement new catch keyword for exception handling.

Please describe in detail how you expect this new feature to behave.

There will be no try keyword, just catch:

let result = potentiallyFailingExpression() catch {
  defaultResultIfAnExceptionOccurs();
};

GML-like try/catch blocks can be written in Catspeak like:

do {
  potentiallyFailingExpression();
} catch ex {
  show_message("failed! {0}", ex);
}