Created
September 1, 2015 13:37
-
-
Save vbilopav/4e0575af9f81c1a92b31 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class WcfErrorHandler : IErrorHandler | |
{ | |
public bool HandleError(Exception error) | |
{ | |
return false; | |
} | |
public void ProvideFault(Exception error, MessageVersion version, ref Message fault) | |
{ | |
if (error == null) | |
{ | |
return; | |
} | |
Log.Error(error, source: error.Source); | |
} | |
} | |
[AttributeUsage(AttributeTargets.Class)] | |
public class WcfErrorHandlerAttribute : Attribute, IEndpointBehavior, IServiceBehavior | |
{ | |
public void Validate(ServiceEndpoint endpoint) | |
{ | |
} | |
public void AddBindingParameters(ServiceEndpoint endpoint, BindingParameterCollection bindingParameters) | |
{ | |
} | |
public void ApplyDispatchBehavior(ServiceEndpoint endpoint, EndpointDispatcher endpointDispatcher) | |
{ | |
endpointDispatcher.ChannelDispatcher.ErrorHandlers.Add(new WcfErrorHandler()); | |
} | |
public void ApplyClientBehavior(ServiceEndpoint endpoint, ClientRuntime clientRuntime) | |
{ | |
} | |
public void Validate(ServiceDescription serviceDescription, ServiceHostBase serviceHostBase) | |
{ | |
} | |
public void AddBindingParameters(ServiceDescription serviceDescription, ServiceHostBase serviceHostBase, Collection<ServiceEndpoint> endpoints, BindingParameterCollection bindingParameters) | |
{ | |
} | |
public void ApplyDispatchBehavior(ServiceDescription serviceDescription, ServiceHostBase serviceHostBase) | |
{ | |
foreach (ChannelDispatcher channelDispatcher in serviceHostBase.ChannelDispatchers) | |
{ | |
channelDispatcher.ErrorHandlers.Add(new WcfErrorHandler()); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment