Chapter 6: TO ERR IS HUMAN Dealing with the Inevitable - Error Conditions in Code
- Errors can and will occur.
- Take error handling seriously. The stability of your code rests on it.
- Never ignore an error condition. If you don’t know how to handle the problem, signal a failure back up to the calling code. Don’t sweep an error under the rug and hope for the best.
- Never ignore any errors that might be reported to you. If an error report channel exists, it’s there for a reason.
- Handle each error in the most appropriate context, as soon as you know enough about it to deal with it correctly.
- Ignoring errors does not save time. You’ll spend far longer working out the cause of bad program behavior than you ever would have spent writing the error handler.
- Write all error detection and handling now, as you write the code that may fail. Don’t put it off until later. If you must be evil and defer handling, at least write the detection scaffolding now.
Jun 28, 2010
comments powered by Disqus