TrapErrors - cConnection

Starts error trapping

Type: Procedure

Parameters: None

Syntax
Procedure TrapErrors 

Call: Send TrapErrors


Description

TrapErrors starts error trapping.

Any error that occurs is now sent to the cConnection object's Error_Report event.

TrapErrors sets piErrorNumber to 0.

TrapErrors needs to be followed by UnTrapErrors. Normally, you want the code between these two events to be as short as possible.

If an error occurs during error trapping, the properties piErrorNumber, piErrorLine and psErrorText are set. This occurs inside of Error_Report. Usually you will test piErrorNumber after error trapping is stopped. If it is non-zero, you can handle the error as you wish. If you wish to report the error, you can use psErrorText to provide an error description. Remember that these properties contain the last trapped error reported. When error trapping is started, piErrorNumber is set to 0.

Procedure LoginAll
    Boolean bOk
    Integer iError
    String sError

    Get LoginAllConnections to bOk
    If not bOk Begin
        Get psErrorText to sError
        Get piErrorNumber to iError
        Send UserError (C_$LoginAllFailedWillAbort + "\n\n" + sError)
        Abort
    End
End_Procedure