Designing for Encapsulation of Behavior in Reusable Handlers

Retired Content

This content is outdated and is no longer being maintained. It is provided as a courtesy for individuals who are still using these technologies. This page may contain URLs that were valid when originally published, but now link to sites or pages that no longer exist.

The latest Enterprise Library information can be found at the Enterprise Library site.

The Exception Handling Application Block lets developers create exception handlers that represent common exception handling tasks. These handlers, as well as combinations of handlers, can be used by different policies.

Design Implications

Encapsulating exception handling behavior into reusable handlers implies two things about the application block's design:

  • There must be a common interface that the handlers implement.
  • Policies must be able to support ordered combinations of handlers.

The next section describes each of these implications.

Common Interface

Application components use a policy name and an exception to indicate to the Exception Handling Application Block the behavior to be performed. The application block provides this behavior by executing the exception handlers configured for the policy. To allow the application block to correctly execute the handlers, all handlers must implement the IExceptionHandler interface. The three handlers provided by the application block all support this interface, but developers can easily write custom handlers that conform to the same interface.

Policy Support for Ordered Combinations of Exception Handlers

Exception handlers can be reused across policies because they typically address single tasks. They can be combined within an exception policy to address more complex tasks. The policy executes the configured handlers in order.

Retired Content

This content is outdated and is no longer being maintained. It is provided as a courtesy for individuals who are still using these technologies. This page may contain URLs that were valid when originally published, but now link to sites or pages that no longer exist.

The latest Enterprise Library information can be found at the Enterprise Library site.
Show: