The Exception Handling Application Block

The Enterprise Library Exception Handling Application Block helps developers and policy makers implement common design patterns and create a consistent strategy for processing exceptions that occur in all architectural layers of an enterprise application. It is designed to support the typical code contained in catch statements in application components. Instead of repeating this code (such as code that logs exception information) in identical catch blocks throughout an application, the Exception Handling Application Block allows developers to encapsulate this logic as reusable exception handlers. The Exception Handling Application Block includes four exception handlers:

  • Wrap handler. This exception handler wraps one exception around another.
  • Replace handler. This exception handler replaces one exception with another.
  • Logging handler. This exception handler formats exception information, such as the message and the stack trace. Then the logging handler passes this information to the Enterprise Library Logging Application Block so that it can be published.
  • Fault Contract exception handler. This exception handler is designed for use at Windows® Communication Foundation (WCF) service boundaries, and generates a new Fault Contract from the exception.

You can extend the Exception Handling Application Block by implementing custom handlers, and administrators can manage the configuration of the block to, for example, turn on additional debugging instrumentation or change the behavior of the block in line with changes to business requirements. The configuration can even be managed using Group Policy tools.

This section includes the following topics that will help you to understand and use the Exception Handling Application Block:

More Information

For more information, see the following Microsoft® patterns & practices guides: