Automatically generated catch in visual studio 2010

Is there a way to automatically generate a "catch" for all possible exceptions that the method can use in vs 2010 or in a third-party application?

For example, if I use "Directory.CreateDirectory", it will automatically create:

try
{
 Directory.CreateDirectory("blabla");
}
catch (PathTooLongException)
{}
catch (DirectoryNotFoundException)
{}
catch (IOException)
{}
catch (ArgumentNullException)
{}
catch (UnauthorizedAccessException)
{}
+3
source share
2 answers

There is a tool that finds unhandled exceptions in your code: Hunter Exception using Red Gate software .

As it turned out, they stopped it:

.NET 4.0 WPF , CLR, . , CLR. , , Exception Hunter , , .

, " , " . , catch-all

try {
    ...
} catch (Exception ex) {
    logAndShowErrorMessage(ex);
}

(WinForms) (WPF: Application.DispatcherUnhandledException, WebForms: Application.Error).

, , , , .


: , , Java, " ": , , . , # :

+1

- , , , . , , , # one , ( , , Java).

, catch(Exception), , Exception. , , , ? ( ) , - , , (, , Directory.CreateDirectory , , , , .

0

All Articles