Error Handling

System Testing for C

The ERROR Statement

The ERROR instruction lets you interrupt execution of a scenario where an error occurs and continue on to the next scenario at the same level.

ERROR instructions follow these rules:

  • ERROR instructions can be located in scenarios, in procedures, or in environment blocks.

  • If an ERROR instruction is encountered in an INITIALIZATION block, the Virtual Tester exits with an error from the set of scenarios at the same level.

Note In debug mode, the behavior of ERROR instructions is different (see Debugging Virtual Testers).

The following is an example of an ERROR instruction:

HEADER "Instruction ERROR", "1.0", "1.0"

#int IdConnection;

SCENARIO Main

COMMENT connection

CALL socket(AF_UNIX, SOCK_STREAM, 0)@@IdConnection

IF (IdConnection == -1) THEN

ERROR

END IF

END SCENARIO

The EXIT Statement

The EXIT instruction lets you interrupt execution of a Virtual Tester. Subsequent scenarios are not executed.

EXIT instructions follow these rules:

  • EXIT instructions can be located in scenarios, procedures, or environment blocks.

  • If an EXIT instruction is encountered, the EXCEPTION blocks are not executed.

The following is an example of an EXIT instruction:

HEADER "Instruction EXIT", "1.0", "1.0"

#int IdConnection;

SCENARIO Main

COMMENT connection

CALL socket(AF_UNIX, SOCK_STREAM, 0)@@IdConnection

IF (IdConnection == -1) THEN

EXIT

END IF

END SCENARIO

Related Topics

Exception Environment (Error Recovery Block) | Environments | Initialization Environment | Termination Environment