0

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?

MuazzamAli
  • 201
  • 2
  • 11
  • It sounds like a good approach. Very similar to [Implementing Exception Management, Part 1](http://msdn.microsoft.com/en-us/library/hh323704.aspx) (scroll down to the ExceptionInterceptionBehavior). – Randy Levy Nov 04 '11 at 16:55

1 Answers1

-1

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

Adrian Thompson Phillips
  • 6,893
  • 6
  • 38
  • 69