On Nov 11, 10:50 am, OliE <[email protected]> wrote:
> Hi all,
>
> my co-worker and I had an argument about try catchs, so I thought
> about asking everyone here since I can't find an answer over my
> internets :P
>
> I found something I find weird in one of his try catch in his code.
> Instead of having multiple catch of different error types, he made
> this :
>
> Catch ex As Exception
> If ex.Message = "IOException" Then
> MsgBox("Communication Error")
> Else
> MsgBox(ex.Message) 'ex.Message
> End If
>
> I told him no to do so and use multiple catchs like this :
>
> Catch exIO As IO.IOException
> MsgBox("Communication Error")
>
> Catch ex As Exception
> MsgBox(ex.Message)
>
> But he is sure his method is faster / resource friendly than mine,
> while I think comparing strings takes longer than catching directly
> the exception.
>
> So, who's right ?
>
> Thanks for future answers and please excuse my english, my main
> language is french :)
So does this miss IO exceptions?
Catch ex As Exception
MsgBox("Error: " & ex.message)
End Try