2 using System.Collections.Generic;
4 using System.ServiceModel.Channels;
5 using System.ServiceModel;
7 namespace System.ServiceModel.Dispatcher
9 internal class ErrorProcessingHandler : BaseRequestProcessorHandler
11 public ErrorProcessingHandler (IChannel channel)
13 duplex = channel as IDuplexChannel;
16 IDuplexChannel duplex;
18 protected override bool ProcessRequest (MessageProcessingContext mrc)
20 Exception ex = mrc.ProcessingException;
21 DispatchRuntime dispatchRuntime = mrc.OperationContext.EndpointDispatcher.DispatchRuntime;
23 //invoke all user handlers
24 ChannelDispatcher channelDispatcher = dispatchRuntime.ChannelDispatcher;
25 foreach (IErrorHandler handler in channelDispatcher.ErrorHandlers)
26 if (handler.HandleError (ex))
29 FaultConverter fc = FaultConverter.GetDefaultFaultConverter (dispatchRuntime.ChannelDispatcher.MessageVersion);
31 if (!fc.TryCreateFaultMessage (ex, out res))
33 mrc.ReplyMessage = res;
35 mrc.Reply (duplex, true);