#
CwClearError

### Syntax:

    call CwClearError()

### Description:

P>G PRO responds to errors by raising a syntax error condition. Normally, this is sufficient. However, occasionally a script must be able to recover from an error. In that case, the script must use "SIGNAL ON SYNTAX" to trap the error and it can become extremely useful to know more about the error.

This function clears the error message and function name that is returned by CwErrorFun and CwErrorMsg, causing them to once again return the empty string. It should be used once the error has been dealt with so that it is possible to determine whether a subsequent trapped error was raised by REXX or P>G PRO. See the section on error handling for more details.

### Example:

    /* Function to attempt to load the requested project and return a flag
       to indicate success or failure, displaying an error message if
       appropriate. */

    loadFile:procedure
    parse arg projectFile

    signal on syntax name cantload		/* Trap syntax errors.*/
    call CwImportProject projectFile

    /* Success.  Switch trapping off and return. */
    signal off syntax
    return 1

    /* Failure.*/
    cantload:
    signal off syntax

    /* Check if the error isn't really something in the REXX end. */
    msg = CwGetErrorMsg()
    if msg = '' then do
    	say "REXX syntax error."
    	exit
    	end
    else do
    	/* OK, it's ours.  Print an error message, clean up and return.*/
    	say 'Error: ' msg 'in' CwGetErrorFun()
    	call CwClearError
    	end
    return 0

Functions by NAME | Index | Functions by PURPOSE