Skip to content
ExamplesOpen editor ↗

tshwara

→ catch

Handles errors raised inside the preceding `leka` block.

leka { ... } tshwara (lebitso) { ... }

Use tshwara immediately after a leka block. The parenthesised binding (e.g. (e)) receives the thrown value so your code can inspect or report it. If no error occurs in the leka block, the tshwara block is skipped.

Log a caught error to the console
leka {
  latlha "phoso";
} tshwara (e) {
  kwala(e);
}

leka, kgabagare, latlha