Skip to content

66 Exception handling ​

throw interrupts normal execution; the matching catch Exception error handles it, and the program continues after the try statement.

norm
import std.core.Exception

Void fail() {
  throw Exception(message: "unavailable")
}

main() {
  try {
    fail()
  } catch Exception error {
    printLine(error.message)
  }
  printLine("continued")
}

Expected output:

text
unavailable
continued

Try it: Remove the catch and observe the unhandled exception.

Precise rules: Reference.

Norm 0.25