Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Try/Catch
Message
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Titre:
Divers
Thread ID:
00802432
Message ID:
00802704
Vues:
20
This message has been marked as a message which has helped to the initial question of the thread.
Eddie,

I would suggest to put all your code inside the TRY/CATCH block. Also, notice that CATCH has the option to "filter" errors, so that you can catch errors that you know how to handle (e.g. cannot open file for exclusive use) and let someone else (e.g.the caller program) deal with other errors.

I usually discourage people from using CATCH WHEN .T. since this will "eat" all errors, and your code most likely will not know how to deal with all errors. However, if you do add a CATCH WHEN .T. -- try to rethrow the exeption so that the caller program can deal with it (see commented code below).
try
    use customer excl
    close all
    do backups
catch TO oEx WHEN oEx.ErrorNo=3
    messagebox('Unable to Open Files Exclusive')
* catch
*   messagebox('something else went wrong')
*   throw
endtry
SET MARKETING ON
Here is yet another reference on Try/Catch:
http://www.levelextreme.com/magazine/june2003/page28.asp
SET MARKETING OFF
Hector Correa
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform