Skip to content

Try, Catch, Finally, and Throw

Exceptions describe recoverable runtime failures. Use structured Control blocks to handle them.

  1. Choose Control → Try and put the protected body inside its brackets.
  2. Follow it with typed Catch blocks.
  3. Configure each Catch with a Private, non-null Throwable/Exception-compatible Variable.
  4. Put more specific exception types before broader ones.
  5. Add Finally for cleanup that must run regardless of the result.
Try
Body: operation that may fail
Catch: Private Exception error
Body: show or record a useful failure message
Finally
Body: restore temporary round state

To replace a structured Control with an ordinary operation, remove and replace it explicitly; its nested body should not be silently discarded.

Exception extends Throwable. A custom instance class may extend Exception. Managed fields include message, nullable cause, and a generated stack String. Throw requires a non-null Throwable-compatible object.

Native operation failures become Exceptions. Throw does not mean sending a Minecraft projectile; it raises the configured failure object through the task’s handlers.

An awaited method failure can be caught by the caller. An unhandled failure stops its own task, reports source/build/call-stack information, and leaves unrelated tasks running. A detached method does not propagate its error back as an awaited result.

Finally runs after normal completion, errors, returns, Break, and Continue. A normal Finally may suspend. Cancellation permits only bounded cleanup with no suspension or new tasks.

Resource failures such as heap/task/frame limits, execution budgets, and regex work limits are fatal. Catch cannot intercept them, and Finally cannot suppress them. Design bounded work rather than using Try/Catch to attempt an unlimited loop.

Use /plot diagnostics and /plot diagnostics error to locate a reported failure. Preserve useful context rather than catching everything and silently ignoring it. When the draft differs from the failing build, inspect the revision before editing the wrong block.