Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
TRY...CATCH: tries but doesn't catch
Message
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
00876740
Message ID:
00876763
Views:
10
I need to add to the following that the test I am running has a field that is not marked as a primary key and does contain duplicate 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
Previous
Reply
Map
View

Click here to load this message in the networking platform