According to MSDN, it is a bad practice to catch exceptions without a specific type and using for example System.Net.Exception
Do I have to dig into the msdn manual to see the possible exception types each time I'm going to catch an error. Or is there any way in the IDE to let me see this quickly.
Currently I'm using Visual Studio 2013 Express Edition
try
{
using (WebClient goog = new WebClient())
{
goog.DownloadString("http://google.com");
}
}
catch(Exception E)
{
saveLog("methodname", E.Message);
}
EDIT : In this link, it looks like VS already has an option to display exeptions, however, when I'm selecting a method, it only shows the type, and the parameters of the method. But it doesn't show exceptions
The best practice is, generally, to only add handling for exceptions you expect to occur during the run-time of your program.
If you're dealing with files, for example, handling the ***NotFoundException types makes sense. Proper coding will ensure things like ArgumentNullException don't happen, so that doesn't need handling, etc.
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