
211
This is the Title of the Book, eMatter Edition
Copyright © 2008 O’Reilly & Associates, Inc. All rights reserved.
Chapter 10Error Handling
10
Error Handling, Debugging,
and Tracing
Most code samples in this book don’t include code intended to handle errors. It’s
not that error handling isn’t important, but error handling can add complexity,
and for the most part we’ve tried to keep the sample code as simple and clear as
possible. Since you’ll need to deal with errors in the real world of application
programming, the first part of this chapter discusses the variety of techniques
available in ASP.NET for handling errors, including custom error pages and struc-
tured exception handling—a new feature of Visual Basic .NET.
In addition to handling errors in ASP.NET applications, most developers want to
figure out what’s causing those errors. To that end, the latter part of this chapter
discusses debugging using either the .NET Framework SDK debugger or Visual
Studio .NET. The chapter also covers use of the ASP.NET trace feature to trouble-
shoot application problems.
Error Handling
The goal of error handling (also known as exception handling) is quite simple: to
prevent exceptions or errors thrown during the execution of an application
request from reaching users. Ideally, users should not know that an exception
occurred, or they should at least be provided with an informative message that
tells them