File: System\ServiceModel\Dispatcher\WebFaultFormatter.cs
Project: ndp\cdf\src\NetFx35\System.ServiceModel.Web\System.ServiceModel.Web.csproj (System.ServiceModel.Web)
//-----------------------------------------------------------------------------
// Copyright (c) Microsoft Corporation.  All rights reserved.
//-----------------------------------------------------------------------------
using System;
using System.ServiceModel.Channels;
using System.Runtime;
 
namespace System.ServiceModel.Dispatcher
{
    class WebFaultFormatter : IDispatchFaultFormatter, IDispatchFaultFormatterWrapper
    {
        IDispatchFaultFormatter faultFormatter;
 
        internal WebFaultFormatter(IDispatchFaultFormatter faultFormatter)
        {
            this.faultFormatter = faultFormatter;
        }
 
        public MessageFault Serialize(FaultException faultException, out string action)
        {
            try
            {
                return this.faultFormatter.Serialize(faultException, out action);
            }
            catch (Exception e)
            {
                if (Fx.IsFatal(e))
                {
                    throw;
                }
                action = null;
                return MessageFault.Default;
            }
        }
 
        public IDispatchFaultFormatter InnerFaultFormatter
        {
            get
            {
                return this.faultFormatter;
            }
            set
            {
                this.faultFormatter = value;
            }
        }
    }
}