Documentation menu

Core Language

Error Handling

try / catch — no exception hierarchy, every caught error is just a message string.

New to coding?

Copy the examples exactly first. Run them. Then change one number or word and run them again. You are not expected to memorize the command lists.

1

try / catch

The catch variable is optional.

Try this code
try {
    n = to_num("not a number");
} catch err {
    print "failed: {err}";
}

try { risky(); } catch { }   // swallow silently
2

assert

Throws a catchable error when the condition is falsy — the standard way to signal failure.

Try this code
fn withdraw(balance, amount) {
    assert(amount <= balance, "insufficient funds");
    return balance - amount;
}
3

Helpful error messages

Runtime errors point at the exact source location and suggest fixes for typos.

Try this code
print greeet("World");
       ^^^^^^
mko: error (line 4): function 'greeet' wasn't found
  hint: did you mean 'greet'?