There is sometimes that one want to do the same on two different types of Exception. I searched, but I didn't find anything for VB.NET.
Simple example:
Try
'...
Catch ex As Net.WebException
'Do something
Catch ex As Net.CookieException
'Do the same
Catch ex As Exception
'...
End Try
I wonder if there is a way to catch both exceptions at once without needed to repeat code.
As seen on Catch multiple exceptions at once? it can be done this way:
Catch ex As Exception When TypeOf ex Is FormatException OrElse TypeOf ex Is OverflowException
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With