Multiple TRY Statements

It is possible for multiple TRY statements to be in effect at the same time (for example, because a TRY statement invoked a procedure that also invoked a TRY statement). If multiple TRY statements are in effect, and a termination condition occurs, the system invokes the error-handling code in the most recent TRY statement. If the termination condition can be handled only by an unsafe TRY statement, then the system invokes the most recent protected TRY statement and bypasses any safe TRY statements that are more recent.

For example, Multiple TRY Statements shows a process stack that has three TRY statements in effect.

Figure 1. Multiple TRY Statements

Multiple TRY Statements


In this example, if a condition occurs that can be handled by a safe TRY statement, the system then executes the TRY statement in procedure PROCD. If a condition occurs that can be handled only by an unsafe TRY statement, then the system executes the TRY statement in procedure PROCC instead.