Chapter 5

Error Management

What's in This Chapter?

Trapping exceptions with try...catch blocks

Managing exceptions in XSL renderings, sublayouts, and web controls

Handling exceptions at the application level with the global.asax file

Redirecting to friendly error pages

This chapter describes error-management techniques that you can use with Sitecore solutions, including some provided by ASP.NET itself. You can trap errors at a number of layers, including the code, component, page, and application levels. This chapter covers error-management facilities from the lowest layer up to the highest.

Sitecore error management applies only to HTTP requests handled by Sitecore, which handles most of the requests that IIS handles with ASP.NET. As described in this chapter, Sitecore error management varies according to the configuration defined under the /configuration/system.web/customErrors element in the Web.config file.

Sitecore attempts to log every exception that it encounters. Such log entries include stack traces. An optimized Sitecore solution should log few or no exceptions. You should attempt to identify all potential errors in development and test environments before deploying that code to production. For more information about Sitecore logging, see Chapter 6. For more information about error management with the Sitecore ASP.NET content management system (CMS), see The Sitecore Presentation Component API Cookbook (http://bit.ly/r76c6K). In fact, much of the information and code ...

Get Professional Sitecore Development now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.