This project is read-only.

How to create an error handler to log details of faults for auditing purposes

J.D. Meier, Jason Taylor, Prashant Bansode, Carlos Farre, Madhu Sundararajan, Steve Gregersen.

You can create an error handler to log the fault details by implementing the IErrorHandler interface methods in your service. By using this you log and suppress the exceptions or you can log and throw them as FaultException.
public interface IErrorHandler 
        bool HandleError(Exception error, MessageFault fault); 
        void ProvideFault(Exception error, ref MessageFault fault, ref string faultAction); 

To suppress the fault message, implement the HandlerError method and return false. In this method you can add your code for logging capabilities.
To raise FaultException instead of suppressing, implement the ProvideFault method to provide the MessageFault value. The following code shows a sample implementation of the ProvideFault method
//code snippet
public void ProvideFault(Exception error, MessageVersion version, ref Message fault)
  FaultException newEx = new FaultException();
  MessageFault msgFault = newEx.CreateMessageFault();
  fault = Message.CreateMessage(version, msgFault, newEx.Action);

Last edited May 8, 2008 at 4:36 AM by prashantbansode, version 1


No comments yet.