We are currently in the first stages of extensive application rewrites from Access VBA & Access Databases to C#.Net & SQL Server databases, and I have a general question regarding the use of structured error/exception handling.
I am used to the unstructured handling that is part of VBA, and can see that the offerings of C#.Net are far more powerful. I have done a lot of reading, but am struggling to find any examples with enough meat on them to clearly demonstrate what the authors are talking about. They are fast and free with what to do and not do, but there are rarely any solid examples to back up the text.
It is clear that I should be shot without question if I catch a general Exception, and that a routine should catch & handle errors that it's own code causes, but errors caused by external factors should just be passed back (bubbled up I think the phrase is), but my question is this:
If your routine uses a function such as opening a file the name of which is passed as a parameter, should it trap every possible exception that is returned by the File.Open in a specific catch block, or is this overkill?? Should it only handle the IOException and then bubble up exceptions that are to do with invalid filename or directory as it was not responsible with generating the filename/path??
I know this is a basic question, but I want to be sure to get the exception handling right at the start of this long path rather than set off along the wrong route and have to go back.
Some examples or link to examples with meat to them that show best practices would be greatly appreciated.