Error Event

Occurs when there is a run-time error in a method. The Error event makes it possible for an object to handle errors.

PROCEDURE Object.Error
LPARAMETERS nError, cMethod, nLine

Parameters

  • 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 overrides the ON ERROR routine and allows each object to trap and handle errors internally.

Note   The Error event occurs only when the error occurs in code. Additionally, the Error event does not occur if the Error Event method does not contain code.

Any errors that occur in an object's Error event must be handled by the object and are not escalated to an ON ERROR routine or TRY...CATCH...FINALLY handler.

Note   The Error event does not occur if an ON ERROR routine is on the call stack.

See Also

ON ERROR Command | TRY...CATCH...FINALLY Command

Applies To: CheckBox | Collection Class | Column | ComboBox | CommandButton | CommandGroup | Container Object | Control Object | Cursor | CursorAdapter Class | Custom | DataEnvironment | EditBox | Exception Class | Form | FormSet | Grid | Header | Image | Label | Line | ListBox | OLE Bound Control | OLE Container Control | OptionButton | OptionGroup | Page | PageFrame | ProjectHook Object | Relation | Session Object | Shape | Spinner | TextBox | Timer | ToolBar