What error handling should be used in VB.NET?
Should one use the “On Error Goto ErrorHandler ... Exit Sub ErrHandler ... End Sub” pattern or should you use the “try { ... } catch { ... } finally { ... }” pattern?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The most obvious reasons I can think of off the top of my head to steer clear of
On Error GoTo...would have to be:On Error GoTodoes not discriminate between types of exceptions.On Error GoTodoes not provide as much structure asTry/Catch/Finally(e.g., nesting oneTry/Catchblock within another).On Error GoTohas no counterpart toFinally(that I know of).I’m sure in many cases, clever use of
On Error GoTocould mimic the behavior that is built in to VB.NET’sTry/Catch/Finallyfeature. But what would be the point?