Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How to trap errors with ON ERROR while error event in pl
Message
From
12/02/2002 03:17:14
 
 
To
11/02/2002 22:12:01
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
00618670
Message ID:
00618702
Views:
22
>Does anyone know of a way to set an ON ERROR statement in a prg and not have an actual Error passed back up to an Error() Event in an object that called the prg?
>
>For instance, in the CodeMine framework, Error trapping code is in the application object Error() event as well as in other classes. I want to call a utility prg which does its own error trapping. However, the ON ERROR's in the prg get ignored. I would really like a way to override the errors being passed up to the error event, and trap them right there.
>
>It seems that VFP needS an optional switch on the ON ERROR statement that will allow an ON ERROR statement to supercede an Error() event.
>
>
>For example, my prg might have code as follows:
>
>m.lcSavOnError= on("error")
>m.llFlag= .f.
>ON ERROR m.llFlag= .t.
>
>Use mytable
>
>ON ERROR &lcSavOnError
>
>if m.llFlag
> *..display error we got when using table
>endif
>
>Thanks in advance.

Mark,

For what it is worth, this is the way I do it with forms

normal on error : ON ERROR Error_(Error(), Program(), LineNo() )

which starts with
procedure Error_(nError, _program, _lineno  )
form.Error routine
LPARAMETERS nError, _program, _lineno

this.LockScreen = FALSE
assert nError==Error()
private  __Object_with_Error__	&& for error handler
private __LineNoPassed__	&& for error handler

__Object_with_Error__ = this
__LineNoPassed__ =  _lineno


local s
s = on('error')
&s

release __Object_with_Error__, __LineNoPassed__
In the error routine I test for the existance of __Object_with_Error__

so the following routine works as expected, even in a form
private HadError
HadError = FALSE
local sError
sError = on('Error')
on Error HaddError = TRUE

use SomeTable excl
on error &sError

if( HadError )

else


endif
Gregory
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform