Figure 3.2: Syntax for
The else portion of the iferr block is optional. The meaning of an iferr block is that if an error occurs (i.e., if error() was called by one of the statements in the block) while executing the statements checked by the block, then execute the following code, but otherwise execute the code in the else block. The normal action of the error procedure, which is to print a message on the standard error stream, is suppressed. The syntax of an ifnoerr block is the same as that of the iferr block, except that the keyword iferr is replaced by ifnoerr. The meaning of an ifnoerr block is the opposite of that of the iferr block. If no error occurs during the execution of an ifnoerr block, then the following code is executed, otherwise the else block is executed. The following example shows the two forms of the iferr block.
If there is more than one procedure call in a given block, then errchk() all of them except the last (see below).
- Figure 3.2: - Syntax for iferr.