When option in Try...Catch

Paul Vick explain how you can use the option When in a Try...Catch to execute some action when you have an exception (like logging the exception)

Instead of:

Sub DoWork()
Try
' Do some work
Catch ex As Exception
LogException(ex)
Throw
End Try
End Sub

Use:

Sub DoWork()
Try
' Do some work
Catch ex As Exception When LogException(ex)
' Do no work
End Try
End Sub

Read more here

 

No Comments