On_Error Command

Description:

This command allows Script errors to be captured, and Script execution to be resumed at a predefined label. The On_Error handler is local to all sections of the Script; it is NOT propagated to called Scripts.

All Script errors, such as a trying to opening a non-existing file, or an attempt to call a nonexistent Script, may be intercepted and dealt with by this command.
If a Script error is encountered, then a message is written in the audit log, identifying and locating where the error occurred.

An On_Error handler may be overridden by another On_Error command.
When On_Error checking is established, it can be disabled by using the Cancel_On_Error Command.
 

Format:

On_Error Goto labelName

Parameters:

labelName

A label defined within the current scope of the Script.

Example:

FILE fileid;

BEGIN

On_Error Goto MyLabel;

log "Open file";
// Try to open a non-existing file
Open "filename.txt" As fileid For Input;
log "File was opened successfully";

Close fileid;

MyLabel:
    log "Error opening file";

Output:

Open file
Error opening file

See Also:





Go back to the Learning center:


Copyright © AgileLoad. All rights reserved.
Agile Load testing tool| Contact AgileLoad | Terms of Use | Sitemap