Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Errorhandling
Message
 
À
08/01/2015 10:09:26
Lutz Scheffler
Lutz Scheffler Software Ingenieurbüro
Dresden, Allemagne
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Titre:
Versions des environnements
Visual FoxPro:
VFP 9 SP2
OS:
Windows 8.1
Network:
SAMBA Server
Database:
Visual FoxPro
Application:
Desktop
Divers
Thread ID:
01613303
Message ID:
01613314
Vues:
113
Bottom line to all of this is you should not mix TRY/CATCH with Error methods in your own objects. Any called objects that have their own error handling with Error methods or TRY/CATCH will work correctly but your own code should avoid mixing the two.

It can get very confusing to debug when both are present.

I went through this with Web Connection which originally relied on Error methods and then switched over to TRY/CATCH. Some other objects would have Error methods and so the error wouldn't bubble and just get eaten.

Personally I don't use Error events any more because they have always been a pain - but they were the only thing we had to internalizing errors in objects. TRY/CATCH is just much cleaner as you can deterministically cover blocks of code.

In your ADDOBJECT/NEWOBJECT code you can probably create factory methods that are wrapped with TRY/CATCH blocks to deal with that scenario.

+++ Rick ---

>Hi all,
>
>I have a problem wit TRY CATCH errorhandling
>Example
>
>lomu = NEWOBJECT('mu')
>
>add_p(_SCREEN)
>
>lomu.add_x
>
>
>DEFINE CLASS mu AS CONTAINER
> PROCEDURE ERROR
>  LPARAMETERS;
>   tnError,;
>   tcMethod,;
>   tnLine,;
>   tvReturn
>
>  ?'Error event'
> ENDPROC &&mu.error
>
> PROCEDURE add_x
>  add_p(THIS)
> ENDPROC &&mu.add_x
>ENDDEFINE &&mu as session
>
>
>PROCEDURE add_p
> LPARAMETERS lomu
> TRY
>   ?lomu.NAME
>   lomu.ADDOBJECT('mux','xxr')
>
>   ?'not catchedd'
>
>  CATCH TO loException
>   ?'catchedd'
>  FINALLY
>*
> ENDTRY
>ENDPROC &&addp
>
>
>As you can see the call for the object will not be catched by TRY CATCH
>
>if there is no ERROR event then it is catched
>
>Any idea how catch the error? This is a example for my factory and it fails to catch the problems ...
>
>Thanks
>
>Lutz
+++ Rick ---

West Wind Technologies
Maui, Hawaii

west-wind.com/
West Wind Message Board
Rick's Web Log
Markdown Monster
---
Making waves on the Web

Where do you want to surf today?
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform