| | | 1 | | // Licensed to the .NET Foundation under one or more agreements. |
| | | 2 | | // The .NET Foundation licenses this file to you under the MIT license. |
| | | 3 | | |
| | | 4 | | using System; |
| | | 5 | | using System.Collections.Generic; |
| | | 6 | | using System.Globalization; |
| | | 7 | | using System.Runtime.Serialization; |
| | | 8 | | using CoreWCF.Channels; |
| | | 9 | | using CoreWCF.Runtime; |
| | | 10 | | |
| | | 11 | | namespace CoreWCF.Dispatcher |
| | | 12 | | { |
| | | 13 | | internal class WebFaultFormatter : IDispatchFaultFormatter, IDispatchFaultFormatterWrapper |
| | | 14 | | { |
| | | 15 | | private static MessageFault s_defaultMessageFault; |
| | | 16 | | |
| | 163 | 17 | | internal WebFaultFormatter(IDispatchFaultFormatter faultFormatter) |
| | | 18 | | { |
| | 163 | 19 | | InnerFaultFormatter = faultFormatter; |
| | 163 | 20 | | } |
| | | 21 | | |
| | | 22 | | public MessageFault Serialize(FaultException faultException, out string action) |
| | | 23 | | { |
| | | 24 | | try |
| | | 25 | | { |
| | 2 | 26 | | return InnerFaultFormatter.Serialize(faultException, out action); |
| | | 27 | | } |
| | | 28 | | catch (Exception e) |
| | | 29 | | { |
| | 0 | 30 | | if (Fx.IsFatal(e)) |
| | | 31 | | { |
| | 0 | 32 | | throw; |
| | | 33 | | } |
| | | 34 | | |
| | 0 | 35 | | action = null; |
| | 0 | 36 | | return Default; |
| | | 37 | | } |
| | 2 | 38 | | } |
| | | 39 | | |
| | 165 | 40 | | public IDispatchFaultFormatter InnerFaultFormatter { get; set; } |
| | | 41 | | |
| | | 42 | | private static MessageFault Default |
| | | 43 | | { |
| | | 44 | | get |
| | | 45 | | { |
| | 0 | 46 | | if (s_defaultMessageFault == null) |
| | | 47 | | { |
| | 0 | 48 | | s_defaultMessageFault = MessageFault.CreateFault( |
| | 0 | 49 | | new FaultCode("Default"), |
| | 0 | 50 | | new FaultReason(""), |
| | 0 | 51 | | null, |
| | 0 | 52 | | null, |
| | 0 | 53 | | "", |
| | 0 | 54 | | ""); |
| | | 55 | | } |
| | | 56 | | |
| | 0 | 57 | | return s_defaultMessageFault; |
| | | 58 | | } |
| | | 59 | | } |
| | | 60 | | } |
| | | 61 | | } |