Domain: PROCEDURE
Command description
IF-BLOCK-ERROR initiates a command sequence which is executed in the following instances:
if an error occurred in the current block
if an error occurred in a block nested in the current block and was not intercepted before leaving this nested block.
An ELSE branch can be defined in the IF-BLOCK-ERROR block, using the ELSE command. The IF-BLOCK-ERROR block is terminated with the END-IF command.
If the IF-BLOCK-ERROR command is called even though an error did not occur, the ELSE branch is executed - if present - or command execution resumed after the related END-IF command. If the command return code is to be evaluated when no error has occurred, either in the ELSE branch or after the END-IF command, a SAVE-RETURNCODE command must be entered before the IF-BLOCK-ERROR command.
Format
IF-BLOCK-ERROR |
Command return codes
(SC2) | SC1 | Maincode | Meaning |
0 | CMD0001 | No error | |
1 | CMD0202 | Syntax error | |
1 | SDP0118 | Command in false context | |
1 | SDP0223 | Incorrect environment | |
3 | CMD2203 | Incorrect syntax file | |
32 | CMD0221 | System error (internal error) | |
130 | SDP0099 | No further address space available |
Example
/BL1: BEGIN-BLOCK /... / BL2: BEGIN-BLOCK / ... / “Error 1 occurs here” / ... / END-BLOCK BLOCK = BL2 /... /“Error 2 occurs here” /... /IF-BLOCK-ERROR ... “The error is intercepted here” /... /END-IF /END-BLOCK BLOCK = BL1
Block BL2 is nested in block BL1. Error handling is not carried out in block BL2.
Errors that occur in block BL2 are intercepted by block BL1 in the IF-BLOCK-ERROR block just like errors that occur in Block BL1.