
Writing an Exception Handler
Developing TACL Routines
3–30
107365 Tandem Computers Incorporated
Figure 3-16. Sample Command Shell (Page 4 of 4)
?SECTION exit MACRO == EXIT the exception handler
[#IF condition = 1 |THEN|
#OUTPUT Can not EXIT without resolving the error.
#OUTPUT Must WARMSTART, COLDSTART, or SHUTDOWN.
#OUTPUT
|ELSE|
#OUTPUT Exiting restrictive command shell.
#RAISE EXIT
]
?SECTION cleanup MACRO == delete variables from prev. errors
#SET #BREAKMODE DISABLE
#OUTPUT Performing cleanup procedure
#OUTPUT The Break Key is disabled until cleanup is complete.
[#CASE [name][step]
| WARMSTART1 |
#POP a b
| WARMSTART2 |
#POP a b c d
| COLDSTART1 |
#POP e f
| SHUTDOWN1 |
#POP g h
]
#OUTPUT
#DELAY 200
#SETMANY condition recovery , 0 OFF
#SET #BREAKMODE ENABLE
#OUTPUT Cleanup procedure complete.
Combining Keep and
Release Handlers
The routines in Figure 3-17 show one way to combine a keep handler
(
restricted_caller
) and a release handler (
protected_code
).
Restricted_caller
starts first; therefore, if an exception occurs, control returns to
the processing loop after the exception is processed.
When the user enters a valid command,
restricted_caller
calls
protected_code
to execute the command; that routine, in turn, calls either
do_add
or
do_sub
. If the user presses the BREAK key or an unknown exception is raised
during execution of either of the latter routines, TACL pops the routine and reinvokes
protected_code
. The #CASE function takes the OTHERWISE path, which
performs an orderly deallocation of resources and then raises the same exception.
TACL then pops that routine (the #FILTER function has not yet been executed in the
reinvocation) and returns to
restricted_caller
. The #CASE function in that
routine takes the appropriate path to deal with the exception and restarts the
processing loop.