Errors in code blocks?

agraham

Expert
Licensed User
Question for Erel.

If you recall Klaus had a problem with some legacy code that jumped around, using Goto, inside For..Next and If..End If code blocks. You said that this was the cause of his problem and it was. The thought occurs to me about what happens if, using ErrorLabel(), an error occurs in such a code block and execution jumps to the error label. As this seems equivalent to a Goto does B4PPC handle this properly. It certainly seems to.

If it IS handled gracefully can the error label code safely be outside the code block, typically before the End Sub and preceded by a Return statement?
 

Erel

Administrator
Staff member
Licensed User
ErrorLabel target should be outside any code block (before the End Sub is a perfect place).
ErrorLabel does handle errors inside code blocks and will jump properly to a label outside the code block.
 
Top