
212
|
Chapter 10: Error Handling, Debugging, and Tracing
This is the Title of the Book, eMatter Edition
Copyright © 2008 O’Reilly & Associates, Inc. All rights reserved.
Structured exception handling
New to Visual Basic .NET, and also available in C#, this type of exception
handling allows exceptions to be caught and handled in particular blocks of
code.
These three techniques provide broadest (custom error pages, which can handle
exceptions from any page in the application) to narrowest (structured exception
handling, which handles exceptions for a specific block of code) coverage for
handling application exceptions. Figure 10-1 illustrates the relationship of these
exception handling techniques to both the exception (shown at the center) and
the user, who you’re trying to prevent from encountering the exception.
The following sections describe these techniques and explain how they fit into an
ASP.NET application. Note that you can use all three techniques together, indi-
vidually, or in whatever combination you like. Using all three techniques in
combination would provide broad coverage for most exceptions and more robust
specific exceptions handling, but at the cost of maintaining your exception-
handling logic in more places.
Custom Error Pages
The most general, but arguably the simplest, technique for handling exceptions in
ASP.NET applications is to implement one or more custom error pages.