Export (0) Print
Expand All

Design of the Exception Handling Application Block

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 is designed to achieve the following goals:

  • Encapsulate the logic used to perform the most common exception handling tasks into minimal application code.
  • Relieve developers of the requirement to write duplicate code and custom code for common exception handling tasks.
  • Allow exception handling policies to be changed after they have been deployed and to ensure that changes happen simultaneously and consistently.
  • Incorporate best practices for exception handling, as described in the Design Guidelines for Exceptions.

Figure 1 shows the interrelationships between the key classes in the Exception Handling Application Block.

Ff647139.2f9ab7c1-4c0a-4359-8a42-31e80fb9973d(en-us,PandP.10).png

Figure 1
Design of the Exception Handling Application Block

The client code interacts with the Exception Handling Application Block through the static method HandleException, which is a method of the ExceptionPolicy class. The HandleException method uses a factory to create an object of type ExceptionPolicyImpl for the named policy. The ExceptionPolicyImpl object has a collection of ExceptionPolicyEntry objects. There is one object for each exception type that is specified in the configuration file for the named policy. For each exception type, the ExceptionPolicyEntry object contains a collection of objects that implements the IExceptionHandler interface. The collection is ordered and provides the sequence that the Exception Handling Application Block uses when executing the policy. Each object that implements the IExceptionHandler interface has associated configuration information that is specific to each type of handler.


Ff647139.note(en-us,PandP.10).gifNote:
If you use the Unity Integration approach to create instances of objects from the Exception Handling Application Block, you must use the non-static façade named ExceptionManager. This class exposes the same API as the ExceptionPolicy class static façade. For more information about using the Unity Application Block to create and inject instances of Enterprise Library objects, see Creating Objects Using the Unity Application Block.


Show:
© 2014 Microsoft