#
CwErrorMsg

### Syntax:

    sFunName = CwErrorMsg()

            sFunName        (string) The name of the P>G PRO function or
                            procedure in which the last exception was raised.

### 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 returns the error message returned by P>G PRO in response to the error. If the error did not occur inside a P>G PRO call, this function returns the empty string. In this way, it can be used to determine if a trapped error is a result of a P>G PRO error or other REXX error.

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