"Robust ASP.NET Exception Handling" Sneak Peek
In case you've been wondering where I've been and why I haven't blogged much lately, I've been putting the finishing touches on my latest e-book, Robust ASP.NET Exception Handling (ISBN 978-0-470-50367-6), which will available from Wrox by the end of this month.
(EDIT: Robust ASP.NET Exception Handling is now available.)
This is a book I've wanted to write for a long time. This is such a poorly understood topic, and there is so much bad information/advice/sample code floating around regarding exceptions in .NET, that quite frankly it needed to be written.
In the interest of whetting your appetites, I thought I'd give you all a little sneak peek, and post the abstract and table of contents here.
Abstract
Unravel the mysteries of exception handling in ASP.NET! First, you’ll get a thorough introduction to structured exception handling in the .NET Framework, learn about the Exception class, the related C# language constructs, and how exceptions propagate up the call stack. Then, you’ll delve into a variety of practical topics such as: when, where, and how to properly throw, catch, and handle exceptions in your code; how to employ “defensive programming” techniques to avoid triggering the most common CLR exceptions; adopting exception handling “best practices”, handling exceptions from rich ASP.NET server controls, data-bound controls, data sources, and AJAX asynchronous postbacks; and processing unhandled exceptions at both the page and application levels.
We’ll also walk through the building of a complete, reusable, and fully configurable ASP.NET exception processing framework that extends far beyond ASP.NET’s built-in error handling capabilities. You’ll learn how to collect information about the state of the application when the exception occurred; how to leverage various ASP.NET state-handling mechanisms such as Application, Context, Session, ASP.NET Cache, cookies, and querystrings to store and pass error data; create a friendly, informative, and highly functional custom error UI; show friendly error messages to “normal” visitors while showing detailed error reports only to site managers based on authentication, authorization, or IP; provide a way for users to add their own information to error reports; persist errors to the Windows Event Log, XML files, or a custom database; send detailed error notifications via email and SMS text; and build an administrative dashboard to list, sort, page, view, and manage error logs. Once complete, you’ll learn how to quickly and easily add this new framework to any web site you create using a simple .NET assembly. A complete sample application and C# source code for the exception processing framework is available as a companion download.
Table of Contents
- Introduction
- What is an Exception?
- The Exception Class
- Property Members
- Method Members
- The Exception Class
- Structured Exception Handling
- Handling Exceptions
- Try-Catch
- Type Filtering
- Finally
- Exception Propagation: Part 1
- Throwing Exceptions
- Handling Exceptions
- Exception Handling Best Practices
- Defensive Programming
- Validating Input
- Checking for Error Conditions
- Choosing the Right Exception to Throw
- Exceptions Should Be Exceptional
- Don’t Abuse Exceptions
- Avoid Swallowing Exceptions
- Don’t Try to Handle Everything
- Defensive Programming
- Other Exception Handling Scenarios
- Handling Exceptions in ASP.NET Data Sources
- Handling Exceptions in ASP.NET Data-Bound Controls
- Handling Exceptions in ASP.NET Rich Server Controls
- Handling Exceptions from Asynchronous Postbacks
- Managing Unhandled Exceptions in ASP.NET
- Exception Propagation: Part 2
- The ASP.NET Default Exception Handler
- Page.Error and HttpApplication.Error
- Building a Custom ASP.NET Exception Handler
- The “Fourth Coffee” Sample Site
- The LD.ExceptionHandling Class Library
- Custom Configuration
- Handling and Redirecting
- Collecting Information
- Storing and Retrieving
- Logging and Notification
- Creating a Custom Error UI
- The Error Page
- Pages for HTTP Errors
- The Admin Pages
- Adding the Custom Exception Handler to Your Own Site
- Conclusion
- About the Author
Again, it should be available soon from Wrox. I'll post a short note when it hits the street.
Subscribe to this blog for more cool content like this!