throw — Generates an exception that can be caught with catch


throw message [errortype]


The throw command generates an exception, that can be caught with the catch command. message is a human readable error message, whereas errortype is a code that can be matched by code doing a catch. It can be used as a way for Hecl programs to distinguish between different types of errors in a global catch section of code.


hecl> throw "oh no"
{ERROR {oh no}} {throw 1}
hecl> throw "oh no" USERERROR
{USERERROR {oh no}} {throw 1}