Take a Zen-like approach to coding and accept the fact that bugs will always exist in your codeat least if you write anything significantly large. This statement doesn't imply that you shouldn't try to write bug-free code; it just means you accept the reality of bugs and plan for the worst scenerio. Having a solid framework in place for handling errors is the most important part of an application. Unfortunately, error handling is something that is added to many applications as an afterthoughttacked on at the end with duct tape and bailing wire or, worse yet, written inconsistently throughout the application. Approached like this, these applications force the people who support them to pay the price later. A piece of advice: write your error handling first. Then watch how smoothly things go the next time you develop an application.