Thanks for the replies. I still have a doubt that I might be wrong considering this article :
http://www.codeproject.com/KB/architecture/exceptionbestpractices.aspx?fid=151762&df=90&mpp=25&noise=3&sort=Position&view=Quick&fr=51 My doubt comes from the section "Don't catch (Exception) more than once per thread" What do you think ? On Nov 11, 11: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 anwsers and please excuse my english, my main > language is french :)
