I'm currently in the process of writing my first Windows Forms application. I've read a few C# books now so I've got a relatively good understanding of what language features C# has to deal with exceptions. They're all quite theoretical however so what I haven't got yet is a feel for how to translate the basic concepts into a good exception-handling model in my application.
Would anyone like to share any pearls of wisdom on the subject? Post any common mistakes you've seen newbies like myself make, and any general advice on handling exceptions in a way that will my application more stable and robust.
The main things I'm currently trying to work out are:
- When should I re-throw an exception?
- Should I try to have a central error-handling mechanism of some kind?
- Do handling exceptions which might be thrown have a performance hit compared with pre-emptively testing things like whether a file on disk exists?
- Should all executable code be enclosed in try-catch-finally blocks?
- Are there any times when an empty catch block might be acceptable?
All advice gratefully received!