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:
- What Does the Exception Handling Application Block Do? This topic provides a brief overview that will help you to understand what the block can do, and explains some of the concepts and features it incorporates. It also provides a simple example of the way that you can write code to use the block.
- When Should I Use the Exception Handling Application Block? This topic will help you to decide if the block is suitable for your requirements. It explains the benefits of using the block, and any alternative techniques you may consider. It also provides details of any limitations of the block that may affect your decision to use it.
- Developing Applications Using the Exception Handling Application Block. This topic explains how to configure the Exception Handling Application Block, how to add the block to your applications, how to determine appropriate exception handling policies, how to specify different handling actions, and how to send an exception to the Exception Handling Block.
- Key Scenarios. This topic shows different ways to use the Exception Handling Application Block in your own applications.
- Design of the Exception Handling Application Block. This topic explains the decisions that went into designing the block and the rationale behind those decisions.
- Extending and Modifying the Exception Handling Application Block. This topic explains how to extend the application block by adding custom handlers and formatters. It also gives some advice about how to modify the source code.
- Deployment and Operations. This topic explains how to deploy and update the block assemblies.
More Information
For more information, see the following Microsoft® patterns & practices guides: