Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Try Catch with Catch 2 times
Message
 
 
To
01/06/2021 18:18:28
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
01680817
Message ID:
01680877
Views:
36
>>Could someone create a sample code with Try Catch such that Try will trigger an error and then Catch will trigger an error such that it would go back to the Catch again? That is, where the Catch code fires twice. I have had that condition once (I saw it in the debugger) but forgot how the error in my code triggered it.
>>
>
>Not tested but you might try:
>
>
>TRY
>*  some code that causes an exception to be raised 
>CATCH TO loException
>   TRY
>*       some code that causes a second exception to be raised 
>   CATCH TO loSubException
>      THROW loSubException
>   ENDTRY
>ENDTRY
>
>
>The THROW command is supposed to send the error to the next higher level of the TRY-CATCH-ENDTRY. So the above might do what you are looking for in terms of nesting the TRY command.

Thank you. Your code kind of does what I was "looking" for. Except in the end there is an error "Unhandled Structured Exception"
The reason I asked the question is I was looking for a possible case where my code would fire the code in the CATCH twice. But my code does not have THROW command. Therefore, I could be simply mistaken that my code would do it. I don't know if you read my other threads but in one case the error log (that was written in the CATCH) would record two different errors with just 3 seconds apart. And since I could not duplicate this type of error, I was trying to create a possible scenario.
Again, thank you.
"The creative process is nothing but a series of crises." Isaac Bashevis Singer
"My experience is that as soon as people are old enough to know better, they don't know anything at all." Oscar Wilde
"If a nation values anything more than freedom, it will lose its freedom; and the irony of it is that if it is comfort or money that it values more, it will lose that too." W.Somerset Maugham
Previous
Reply
Map
View

Click here to load this message in the networking platform