Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Which Error event will be called?

Status
Not open for further replies.

androidc

Programmer
May 27, 2003
13
CA
I'm not sure exactly how to describe this problem, but i'll try my best...

We have browwind.scx, a form that contains a grid only, which allows the user to browse and select records from a main table. When a user presses enter, or double clicks, it opens up another window (fiche.scx).

Both screens have private data sessions.

In fiche, i wanted to produce an error, so i created a button (command1) with the following code :

SELECT system
USE
SELECT system
MESSAGEBOX(system.name)


I wanted to produce error 13, "Alias 'system' not found". In a procedure we have, called errorsys, i could catch which error occurred, find the table name, open it if i need to, without having to worry about why the table wasn't open in the first place. (yeah yeah, i know its lazy...)

Neither form has code in their error event. But they share the same base class (_form), which has code that formats errors and sends the data to errorsys.

At first, i thought i wouldn't even have to worry about how errorsys was called (either thru the ON ERROR DO errorsys WITH ... or the Error event, which called errorsys).

What is irking me is that when Command1 is clicked, it selects the table system, then closes it, then tries to select it. right away, i'm in the Error event of browwind, (the first form, with the grid). In the data session of browwind, system is already open!! (forget that its the system table...i never have a problem with that not being open, but i just happened to pick that one to test with..might as well be table 'blah').

One problem i see arising is that let's say it were table blah, which browwind has no need of but fiche does. The code i put to open blah in errorsys (or whatever table wasn't found) will open it in the wrong database. and then i've solved nothing.

My question is, why is the error event of the first form being called and not of the second, which has been fully loaded and which contains the object causing the error?

thanks
 
If i could quote the Hacker's Guide to Visual FoxPro 7.0

"So when does Error fire, anyway? It fires when something in a method of the object causes an error. If you mess up the call to an object's method, though, it's not the called object whose error handler fires, it's the calling object. For example, if a method of cmdDoIt calls the AddItem method of lstMyList, but messes up the call as lstMyList.AddItm, cmdDoIt's Error event fires because it can't find the called method.

"If there's no code at all in the Error method (and nothing in the Error methods all the way up the object's class hierarchy), an object's errors get passed on to the current error handler set up with ON ERROR."


If i understand this properly, command1 is the object in which the error occurs, but it has no code in its error event. So, in the class hierarchy, does the error get passed to command1's form object, fiche, which also has no code in its error event. If the error is to be passed again, will it go to the base class before going to the object that called form (yeah, i skipped over the base class of command1, which also does not have error code).

What i'm seeing is that browwind's error event is being called, but what i don't get is that it should not have error code, only its base class does, which fiche shares, so i understand that it -should- be fiche's error event that is called, which is what i'd really like to happen, so the data environment doesn't change...

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top