Raising Exceptions

Whenever an unexpected error occurs, the throw statement can be used to ``throw'' an exception, and abort the current function (all subsequent commands in the function will be skipped). The program flow is reduced to the user interactive level, unless the thrown exception is caught by a `catch command. The throw statement takes a single parameter, which is an identifier (not quoted) used as the name of the exception. All the exceptions are stored as global names and form their own name space. There is no need to pre-define an exception. At the first time an exception is thrown or caught, the exception will be defined and the name added to the database of exceptions, and can be referred to later.



oz 2009-12-22