Occasionally an error occurs that is not expected:: A subscript of a
out-of-bounds. An attempt to divide by zero. A
Hash is missing a key.
In many cases, the predefined
Result enums are preferable to
raising an exception. However, error classes exist for cases where
Result are not suitable.
The base class of all errors is
Exception. Only classes that inherit from
Exception can be raised. The
Exception class include two members: a
String message, and a
When an exception is raised, the
traceback field of it is replaced with the
current call stack.
Information about exception capture is available in the
try section of blocks
The exception hierarchy is as follows:
DivisionByZero: Attempt to divide or modulo by zero.
Exception: Base class of all raiseable exceptions.
IndexError: Out-of-bounds access of a container (such as
IOError: Incorrect usage of a
KeyError: Attempt to read a value from a
Hash that does not exist.
RuntimeError: Bad runtime action such as modifying a hash during iteration
or exceeding the recursion limit.
ValueError: Invalid or unreasonable value provided.
Any of these exceptions can be inherited to create a custom exception. The try
section in the blocks area details how
try/except works, and more on raising