Chapter 8: Handling Exceptions


Overview

Key concepts in this chapter are:

  • Understanding where exceptions occur

  • Implementing exception handling

  • Determining what information to give when an exception occurs

No one is perfect. No matter how well organized, pre-prepared, and appropriately equipped a person is, things invariably, inevitably, and commonly go wrong. Put it down to lack of perfection, and make this the excuse for why we miss airplane flights, wear inappropriate clothes to social functions, and buy the wrong birthday presents for our spouses. Interestingly, we often expect others to be perfect. This illustrates the old saying, “We judge ourselves by our intentions and others by their actions.” As with other areas of life, the users of computer software are not perfect. Some will enter wrong passwords, attempt to open badly formatted files, and unknowingly delete essential resources from the hard disk. If, after they do any or all of these things, your program doesn’t work as expected, users will blame the software. A term you’ll see throughout this chapter is grace. Just as people should gracefully accept life’s ups and downs, computer software should also handle unforeseen situations with grace.

As developers, we create our software in a friendly environment where everything is set up to work perfectly. However, users will ultimately run software in a less-than-perfect environment where anything can and will go wrong and flaws in your software will be exposed. From a security perspective, software flaws are not only an annoyance; they are vulnerabilities that can be exploited by an intruder to attack the software or the system it’s running on. Designing software to handle exceptions gracefully serves two purposes: it protects against attacks and makes for a more robust and satisfying user experience. Secure software is robust software. Chapter 7 discussed verifying user input and, where possible, preventing exceptions from happening. This chapter discusses what to do when an exception does occur. Unless handled correctly, exceptions cause application errors. Both divide by zero and file not found errors are examples of exceptions.




Security for Microsoft Visual Basic  .NET
Security for Microsoft Visual Basic .NET
ISBN: 735619190
EAN: N/A
Year: 2003
Pages: 168

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net