Compartir a través de


Error Event (Visual FoxPro)

Occurs when an error occurs in a method at run time. You can add Error event code so that the object can handle errors.

Note

The Error event occurs only when the error occurs in code. If the Error event does not contain code, the Error event does not occur. If an ON ERROR routine is already on the call stack, the Error event does not occur.

Tip

Make sure that you include code that handles errors that you cannot anticipate. Otherwise, the Error event code executes but does not take action to handle the unanticipated error, and the default Visual FoxPro error message will not display.

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

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 | ReportListener Object | Session Object | Shape | Spinner | TextBox | Timer | ToolBar

The Error event overrides the ON ERROR routine and makes it possible for each object to detect and handle errors internally.

If any errors occur in the code for an Error event, the object must handle those errors and cannot escalate them to an ON ERROR routine or TRY...CATCH...FINALLY structure.

See Also

Reference

ON ERROR Command

TRY...CATCH...FINALLY Command

Other Resources

Events (Visual FoxPro)

Language Reference (Visual FoxPro)