Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Try Catch with Catch 2 times
Message
From
28/05/2021 22:37:51
 
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
01680817
Message ID:
01680818
Views:
57
Likes (1)
Hi Dmitry.
>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.

To the best of my knowledge, that's not possible. An error in the catch code causes the Try/Catch to fail, not to retrigger.

That said, if the code in the Try part was recursive then it could look like the catch fired twice as the different instances of the same code would be triggering.

Another option is that you didn't actually see the catch being executed again, but rather just saw the way that the debugger highlights the catch line when the catch code fails. For example, if you trace the following code -
Try
	lnBang = NonExistantVariable
Catch to loError
	loError = .NULL.
	lnBang = NonExistantVariable
EndTry
You'll see that when the code in the Catch crashes the cursor moves back to the Catch line, but it doesn't actually catch it again as loError will stay .NULL. and the code in the Catch doesn't execute.

I hope that helps.

Ian Simcock.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform