Error handling

Browser runtime: loading…

Use errors for exceptional paths, rescue them around a block, or put a rescue clause directly inside a method body. Each runnable snippet uses the same WASM engine as the playground.

Errors and rescue

Raise errors with raise. Use begin / rescue, or place a rescue clause directly inside a method body when the whole method has one fallback path.

errors.spr
Press Run to execute this snippet. ⌘↵ runs from the editor.

Next steps

  • Open the playground for a blank editor and the full keyboard shortcuts.
  • Follow Install on the home page to run Sapphire locally.
  • Browse the GitHub repository for the compiler, stdlib, and issues.