Read exception policies

Topics: Exception Handling Application Block, General discussion
Jun 16, 2009 at 10:52 PM

How can I enumerate the exception policies in my config and each one's exception types that are being handled?  Is it possible to get their handlers too?

Jun 17, 2009 at 2:52 AM

Yes, it sure is possible.  Here's a sample code reading exception policies from an app.config/web.config.

            IConfigurationSource configSource = new SystemConfigurationSource();
            ExceptionHandlingSettings ehSettings = (ExceptionHandlingSettings)configSource.GetSection("exceptionHandling");
            foreach (var policy in ehSettings.ExceptionPolicies)
                foreach (var exceptionTye in policy.ExceptionTypes)
                    foreach (var handler in exceptionTye.ExceptionHandlers)

Hope this helps.

Sarah Urmeneta
Global Technology & Solutions
Avande, Inc.