[2008] Comprehensive error handling for jmcilhinney's data access samples
I'd like to request recommended error handling code for jmcilhinney's data access samples
Thanks for any help
Re: [2008] Comprehensive error handling for jmcilhinney's data access samples
1. Look at the members I use and then read the documentation for those members and see what exceptions they can throw.
2. Look at the situations that can cause those exceptions to be thrown and ask yourself whether that situation could reasonably occur in your app.
3. For those exceptions that could reasonably occur, wrap the code in a Try block and Catch the exception.
4. For blocks that can throw more than one type of exception AND you want to process those exceptions differently, add multiple Catch blocks.
5. Make sure that, if one section of code depends on another, the second section will not execute if the first throws an exception, e.g. don't call ExecuteReader if calling Open on your connection threw an exception.
Those are basically the rules of exception handling for any code. So, how about you try following them and show us the result?
Re: [2008] Comprehensive error handling for jmcilhinney's data access samples
Sure thing. Will post the code asap.