Is it bad programming style to have a single, maybe common, generic exception?
- by m0s
Hi, so in my program I have parts where I use try catch blocks like this
try
{
DirectoryInfo dirInfo = new DirectoryInfo(someString);
//I don't know if that directory exists
//I don't know if that string is valid path string... it could be anything
//Some operations here
}
catch(Exception iDontCareWhyItFailed)
{
//Didn't work? great... we will say: somethings wrong, try again/next one
}
Of course I probably could do checks to see if the string is valid path (regex), then I would check if directory exists, then I could catch various exceptions to see why my routine failed and give more info... But in my program it's not really necessary. Now I just really need to know if this is acceptable, and what would a pro say/think about that. Thanks a lot for attention.