Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
TRY...CATCH: tries but doesn't catch
Message
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Divers
Thread ID:
00876740
Message ID:
00876761
Vues:
9
John,

There's no provision in your code for errors other than 1705 and 1884. In that case lcErrorInfo variable isn't assigned any values.

>Hello all,
>I'm messing with an indexing routine and wrapping it in a TRY CATCH:
>
>
>TRY
>     ALTER TABLE myTable ADD PRIMARY KEY id_MyTable TAG id_MyTable	
>CATCH TO oException
>     DO CASE
>          CASE oException.errorno = 1705  &&access denied
>               lcErrorInfo = 'Somebody has the table open.'
>          CASE oException.errorno = 1884  &&uniqueness of index violated
>               lcErrorInfo = 'When trying to index the primary key,  
duplicate entries where found.' + CHR( 13 ) ;	
>+ 'Please fix the data.'
>     ENDCASE
>
>     MESSAGEBOX( 'A problem was encountered while indexing table ' +
 UPPER( ALLTRIM( pcTableName ) ) + ':' + CHR( 13 ) ;
>+ ALLTRIM( oException.message ) + CHR( 13 ) ;
>+ lcErrorInfo, 48 )
>ENDTRY
>
>
>Problem is, it doesn't catch. I've watched it through the debugger, it enters the TRY portion, runs the ALTER TABLE and immediately throw a default VFP error message up. Then it completely bypasses the CATCH. Am I missing something here? Thanks for any insight.
>
>jfh
--sb--
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform