A workable but clumsy solution would be for every system call that could
report an error to return an error code via a result parameter. We chose
to use Modula-2+ exceptions instead. Exceptions have the advantage over
return codes that they can't be accidentally ignored, because an exception
for which no handler exists results in abnormal termination of the
program. Exceptions are handled by
enclosing a statement sequence that could raise an exception with a
TRY ... EXCEPT statement.
A Modula-2+ procedure declaration may include a RAISES clause enumerating the exceptions the procedure may raise. The declaration of an exception may include a parameter, allowing a value to be passed to the exception handler. Most procedures in the Topaz operating system interface can raise the exception Error, which is declared with a parameter serving as an error code, analogous to the UNIX error number. Topaz defines the exception Alerted for reporting thread alerts (discussed in Section 3.3). Each procedure in the Topaz operating system interface that may do an unbounded wait includes Alerted in its RAISES clause. As described in Section 4.3, Topaz also uses exceptions to report synchronous events such as hardware traps.