Programmers can use exception processing to handle cases that interrupt the main flow of control. The advantage of exception processing is that special cases for exceptions do not need to be explicitly coded in the main program flow. This greatly simplifies programs as exception processing can account for much of the code in a program.
Several different types of exception handlers can be coded after a primary method. The handlers share access to any variables that the primary method can access. They may also have their own local variables. Specialized handlers can selectively field specific assertions, method calls, or signalled variables.
catch [retry | fault | call | context | class] [Name ...]
Each handler method ends with a Return command and an optional switch or variable to determine if the method should simply return or propagate the exception up the call chain. The Raise switch always propagates the exception. A variable set to a non-zero value will also propagete the exception. Otherwise the handler will return normally from the primary method.
return [raise | Variable]
catch [retry]
A general handler catches all exceptions not managed by a more specialized handler. If the Retry keyword is coded then all handlers bundled with a primary method can repeatedly raise and catch exceptions. By default a handler that throws an exception will raise a program fault exception.
catch fault
After a program fault only a catch-fault handler can be invoked. Otherwise, any other handlers are skipped for program faults. Retries are permitted in fault handlers when flagged on the general catcher.
catch Local.Exception
An assertion in the primary method can be managed directly by designating a local handler. Several assertions can reference the same local handler.
assert [Condition] catch Local.Exception; [Message]
catch call Method.Name ...
A method called within the primary method or a bundled handler that raises an exception can be managed by a designated handler. If there are several calls to the same method are made they will all be managed by the same handler.
catch context Variable.Name ...
This handler receives control if a variable with a user defined type has an active context. Upon exiting the handler the context will be cleared unless it it the subject of the primary method.
catch class Class.Name ...
All variables of a given user type can be managed by the same handler with this handler. Globals in the class are implicitly Used by the method. Individual variables can be discriminated within the handler using the Context function. It takes a variable as its argument and returns zero if it is not signaled or 1 if it is.
IF context( Variable )