The commands for error handling initiate IF blocks that are processed like “normal” IF blocks. ELSE and END-IF commands are also associated with these IF blocks.
IF-BLOCK-ERROR block
If a command return code with an error flag is returned, SDF-P automatically branches to the next IF-BLOCK-ERROR block; other blocks on lower nesting levels are skipped.
The IF-BLOCK-ERROR command can also be called if an error has not occurred. In this case, the ELSE branch of the IF-BLOCK-ERROR block is executed.
If no IF-BLOCK-ERROR block is present between the command that led to the error and the procedure end, the procedure is terminated and the caller is notified of the error. The error code is transferred to the caller in the same way as for procedure termination with EXIT-PROCEDURE ERROR = *YES.
Example
/BEGIN-BLOCK /"commands" / IF-BLOCK-ERROR / "Error handling / ELSE / "No error" / END-IF /END-BLOCK
IF-CMD-ERROR block
The IF-CMD-ERROR block can be used to perform error handling for the command that directly precedes it but not for block initiation or termination commands. This means that IF-CMD-ERROR cannot be applied to the FOR, IF, REPEAT or WHILE commands or the associated termination commands.
This permits specific error handling for this command and prevents execution of block error handling.
Like the IF-BLOCK-ERROR block, the IF-CMD-ERROR block can contain an ELSE branch that is executed if the IF-CMD-ERROR command is called and the preceding command was executed without error.
Example
/command /IF-CMD-ERROR / "Error handling" /ELSE / "No error in command sequence" /END-IF
Regardless of whether or not an error occurred, the command return code of the command which preceded IF-CMD-ERROR is always available. This permits warnings to be evaluated, even if there was no error, both in the ELSE branch and after command error handling (END-IF).