handling FaultException<T> in a policy handler

Topics: Exception Handling Application Block
Jun 8, 2008 at 4:00 PM
Edited Jun 8, 2008 at 4:00 PM
I am using the exeption handling application block.  I have defined a policy, and I want to assign different handlers to different types of FaultException<T> in this policy.

So, for FaultException<string> I want to replace, and  for FaultException<ArgumentException> I want to re-throw.

I dont want to create a new policy, and I dont really want to modify my code to explicitly catch FaultException<string> and FaultException<ArgumentException>.

What values do I set in the configuration file to be able to handle FaultException<string> and and FaultException<ArgumentException>

Thanks again for the great work on this project.
Jun 19, 2008 at 11:01 PM

Hi,

While you cannot specify it through the configuration editor (the type picker just doesn't like generics), you can add the entry manually in the configuration file like this (of course, using your fault contract instead of TestFaultContract):

   20           <add type="System.ServiceModel.FaultException`1[[ShieldingTest.TestFaultContract2, ClientApp, Version=1.0.0.0, Culture=neutral, PublicKeyToken=46ab5faa18b0cb38]], System.ServiceModel, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"

   21               postHandlingAction="ThrowNewException" name="TestFaultContract2">

   22             <exceptionHandlers>

   23               <add exceptionMessage="Fault" exceptionMessageResourceType=""

   24                 wrapExceptionType="System.InvalidOperationException, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"

   25                 type="Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.WrapHandler, Microsoft.Practices.EnterpriseLibrary.ExceptionHandling, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"

   26                 name="Wrap Handler" />

   27             </exceptionHandlers>

   28           </add>

Hope this helps,
Fernando

 

 


DevilDog74 wrote:
I am using the exeption handling application block.  I have defined a policy, and I want to assign different handlers to different types of FaultException<T> in this policy.

So, for FaultException<string> I want to replace, and  for FaultException<ArgumentException> I want to re-throw.

I dont want to create a new policy, and I dont really want to modify my code to explicitly catch FaultException<string> and FaultException<ArgumentException>.

What values do I set in the configuration file to be able to handle FaultException<string> and and FaultException<ArgumentException>

Thanks again for the great work on this project.


Jun 20, 2008 at 3:58 AM
Yes, that helps a lot.  Thank you very much for taking the time.

Regards