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:
00876771
Views:
10
Sergey,
Sorry, this code is somewhat scaled down. The test I was running had the id_field as REGULAR, not PRIMARY and did contain duplicate values. It should encounter error 1884
thanks,
jfh

>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
Previous
Reply
Map
View

Click here to load this message in the networking platform