Any application should be able to handle all exceptions that occur within it and return 'normal' control to the calling program. PL/I exception-handling facilities and ANYCONDITION ON-units help make this possible.
The first executable statement in any PL/I routine that is called from a non-PL/I routine should be an ON ANYCONDITION statement. This statement should contain code to handle any condition not handled explicitly by other ON-units. If a condition arises that cannot be handled, use a GOTO statement pointing to the last statement that would normally be executed in the routine, for example:
pliapp:
proc( p1, ..., pn )
returns( ... )
options( fromalien );
/* declarations of paramaters, if any */
/* declarations of other variables */
on anycondition
begin;
/* handle condition if possible */
/* if unhandled, set return value */
goto return_stmt;
end;
/* mainline code */
return_Stmt:
return( ... );
end_stmt:
end pliapp;
For PL/I routines that are not functions, the target for the GOTO should be the END statement in the routine.