# Exceptions

Invariably, things go wrong. When those things are inside the VM, it would be
nice to handle them from Ruby code rather than being unceremoniously dumped at
the shell prompt. While C++ has structured exception handling, there is a
special way of throwing an exception that will be propagated into Ruby-land.

The C++ exception is named RubyException, but rather than throwing it
directly, use one of the static methods on the builtin Exception class. For
example, to raise an ArgumentError:

  Exception::argument_error(state, "this failed for some reason");

See also vm/builtin/exception.hpp.

TODO: Document Ruby exception handling in the VM.
