Error Event

Applies To   See Also

Occurs when there is a run-time error in a method.

Syntax

PROCEDURE Object.Error
LPARAMETERS [nIndex,] nError, cMethod, nLine

Parameters

Visual FoxPro passes the Error event three or four parameters in the following order:

nIndex

Uniquely identifies a control if it is in a control array.

nError

Contains the Visual FoxPro error number.

cMethod

Contains the name of the method that caused the error. However, if a method calls a user-defined function, and an error occurs within that function, cMethod contains the name of the user-defined function, rather than the name of the method that called the function.

nLine

Contains the line number within the method or user-defined function that caused the error.

Remarks

The Error event allows an object to handle errors. This event overrides the current ON ERROR routine and allows each object to trap and handle errors internally.

Important   The Error event is called only when the error occurs in code.