Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Try Catch with Catch 2 times
Message
 
 
To
28/05/2021 22:37:51
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
01680817
Message ID:
01680819
Views:
49
HI Ian,

Thank you very much for the explanation and for the example. I probably saw a similar case in the debugger.

I am back to refactoring my code :)

Enjoy your weekend.
>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.
"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