Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Returning a value to a specific program from an error method
Message
De
07/08/2001 20:01:33
 
 
À
Tous
Information générale
Forum:
Visual FoxPro
Catégorie:
COM/DCOM et OLE Automation
Titre:
Returning a value to a specific program from an error method
Divers
Thread ID:
00541056
Message ID:
00541056
Vues:
51
I have had it beat into my head that my COM components shall have NO user contact.

Toward that aim I am attempting to handle errors from within the component. All my custom methods load a cErrorTxt property with what I wish to tell the user and I return .F. from the method to alert the calling program of an error. I have been successful at returning my data using properties of the class (such as .Value) and by passing parameters by referance to load. So, the return(.f.) system has been working well for me.

Here is the problem. What if I don't see the error comming. Something as simple as a typeo (something I have NEVER done :-) ). This causes the Error event to fire. I tried to load custom code into the Error event to save the messages to the cErrorTxt property - no problem. Then I back out of the program hierarchy using the following code:
   LOCAL lnProgram, lcProgram
   lnProgram = PROGRAM( -1 )
   DO WHILE !EMPTY( PROGRAM(lnProgram) ) AND lnProgram > 0 AND ;
         UPPER( ALLTRIM(This.Name) ) $ UPPER( PROGRAM(lnProgram) )
      lnProgram = lnProgram -1
   ENDDO
   lcProgram = PROGRAM( lnProgram )
   RETURN(.F.) TO &lcProgram
(Note: pay no attention to the '()' around the .F. the results are the same with or without them.)

This allows me to "return" to the calling program and is supposed to return .F. to it. However, when single steping, the "return" just returns to the code line following the error ( still in my component ). I was suspicious when I saw the words Procedure Name in the help file on Return. Should have known better.

My question then becomes what do others do to handle this situation of error trapping for COM.

Thanks in advance for your help.

Terry


P.S. Yes I know I need to work on the code above to handle such things as RI errors etc. What I am interested in here is a general principle of error handeling.
It is impossible to make programs idiot proof. Idiots are too cleaver.

MCP( Tcp/Ip )
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform