Setup Exception Handling Application Block via Unity Interception and inject exception policies

1.7k views Asked by At

I am trying to setup Exception Handling Block for my application and would like to inject exception handling policies (defined in configuration file) at the point where I am registering modules and interception with unity in my IoC factory.

For now I am just registering types and setting up interception and using exception behaviours like this:

container.AddNewExtension<Interception>();
container.RegisterType<INotificationService, NotificationService>(
     new TransientLifetimeManager(), new Interceptor<InterfaceInterceptor>(),
     new InterceptionBehavior<ExceptionBehavior>());

Then I am handling exception in the Invoke method of my exception behaviour and applying policies there like this:

exManager.HandleException(ex, policy);

Is this the right way and any ideas or feedback and how can I inject policies when I am setting up the unity container?

1

There are 1 answers

0
chevitasXD On

You can use the policy injection feature within the Enterprise library and use the exception handling handler: https://msdn.microsoft.com/en-us/library/Ff660909%28v=PandP.20%29.aspx