AssertionError
Built-in class · Extends Error
An AssertionError is what a failed assert raises. It extends
Error directly, not RuntimeError, so catch error: RuntimeError does
not catch it: a failed check is a mistake in the program, not something to handle along the
way.
try { assert 1 + 1 == 3}catch error: AssertionError { print(error.message) # prints assertion failed: `1 + 1 == 3`}The message written in the assert, or, when there was none, the condition that failed:
assertion failed: `1 + 1 == 3` .