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 // FIXME: remove them. FaultConverter also covers errors like EndpointNotFoundException, which this handler never covers. And checking converter twice is extraneous, so this part is just extraneous.
30 // FIXME: instead, FaultContractInfos should be checked
31 FaultConverter fc = FaultConverter.GetDefaultFaultConverter (dispatchRuntime.ChannelDispatcher.MessageVersion);
33 if (!fc.TryCreateFaultMessage (ex, out res))
35 mrc.ReplyMessage = res;
38 mrc.Reply (duplex, true);