0

I'm developping a winform application and I would like to make it as robust as possible.

In my code there are classes where I throw exceptions that I master very well and catch them whenever it's needed. However, there are some other classes/methods that throw exception that I may have forgotten and are not thrown in the current testing scenarios.

Let's say for example the class StreamReader The constructor may throw different exceptions that should be handeled (MSDN)

My question is there any tool for VB.Net (which works) that would check if am I instanciating the class StreamReader in a Try and Catch ?

I have been looking to the page : Wiki

I checked also the threads StackOverFlow and StackOverFlow

But none of them really helped me.

I read somewhere that every operation theoretically can throw an exception. Well, the idea is to reduce at least the "first level" exception and at least only for core .Net components that may have been forgotten without necessarily targetting 100% of the exceptions or targetting third parties classes.

If someone has an answer I would appreciate your help :)

Cheers in advance.

Community
  • 1
  • 1
Thomas Carlton
  • 5,344
  • 10
  • 63
  • 126
  • 2
    Of course this could not be your answer, but did you implement the `Application.ThreadException` handler and the `AppDomain.UnhandledException` handler? There two will give a safety point for handling these nasty uncaught exceptions. http://msdn.microsoft.com/en-us/library/system.windows.forms.application.threadexception(v=vs.110).aspx – Steve Jul 26 '14 at 20:41
  • Yes I did but I'm not really interested in simply avoiding a crash of the application by handling these events. I'm interesting in handling exceptions while adding a value to user experience. Thanks though – Thomas Carlton Jul 26 '14 at 22:37
  • 1
    There is no way you can make the program gracefully handle "general" exceptions, providing a distinct user message. There is no first level exception type, programmer needs to decide which exceptions they want to handle. There is no standard way of handling exceptions either. You can find multiple approaches on the internet, but which one to use and how - is up to the programmer to decide. Having said that, you may be able to find a framework that already has those handled, but it is only because someone else wrote the code for it. – Victor Zakharov Jul 26 '14 at 23:21
  • Agree with that. Indeed, there is no way to generally handle any exception. The idea is more when you write "Call ClassA.MethodB()" if the method throws exceptions and it's not written between try/catch, the tool warns you about that and that's it. And you will decide in your code to handle it or not... **It's just to warn you.** Nothing else. Something like : be careful : you are calling a method that may through an exception at run time and it's not handled. – Thomas Carlton Jul 26 '14 at 23:40
  • The classical example is when Visual Studio warns about a **variable that has not been initialized.** It's just a warning and after all, you may decide not to initialize it. – Thomas Carlton Jul 26 '14 at 23:42

0 Answers0