The Effects of the Exception Handler

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 GetCustomerName method of the business object checks for an empty value passed as the customer ID property and throws an ArgumentNullException containing the message, "This exception will be replaced...". The exception handler defined in the policy for the GetCustomerName method replaces this exception with a new Exception instance that contains a more informative message describing the problem. This requires only configuration of the Policy Injection Application Block and Exception Handling Application Block; it does not require any changes to the application code. Figure 1 illustrates the result.

Ff648144.PI-INTRO-CommonScenario6(en-us,PandP.10).gif

Figure 1
The exception handler replaces the ArgumentNullException with a new exception

The ability to capture, wrap, ignore, or replace exceptions raised by code provides a technique to hide information that you may not want available in exceptions, add more informative messages and resolution information, and integrate applications with monitoring environments. With the Policy Injection Application Block, you can set this up and modify it during deployment and operation without changing the application code. It is still necessary to restart the application for updated policies defined in configuration to take effect.

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: