O'Reilly logo

Expert One-on-One™ C# Design and Development by John Paul Mueller

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required