Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.

  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

Part II: Coding Strategies > Implementing Error Handling

Chapter 14. Implementing Error Handling

Your application, no matter how well crafted, examined, optimized, quality controlled, tested, or user stressed, is going to have errors. It's possibly the saddest fact of life for developers, because most developers would like to think that error-free applications are at least possible. However, errors are part of human nature and even if human nature didn't intrude, the law of life is that errors exist in nature as well. The perfect application, should it exist, would have to run on flawed hardware and be used by imperfect users. Consequently, no matter what you do, your application will experience errors. Your best defense against errors is to assume nothing about the application, the hardware, the user, the environment, or anything else for that matter. When you assume nothing, it's less likely that your error handling will contain flaws (although it will likely contain at least a few problems that you'll need to fix).

Error handling becomes more reliable when you use specific error-handling techniques. Using such techniques means relying on an almost engineering view of application design. You apply the error-handling techniques consistently and attempt to solve problems as precisely as possible. Instead of trapping a generic error, you trap specific errors and act on each error according to type. Of course, this type of error handling requires more development time, but it also produces significantly better results. Generally, better error handling costs time and money, but more than pays back the investment you make in it.


  

You are currently reading a PREVIEW of this book.

                                                                                                                    

Get instant access to over $1 million worth of books and videos.

  

Start a Free Trial


  
  • Safari Books Online
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint