| | | 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.Globalization; |
| | | 6 | | using System.Runtime.Serialization; |
| | | 7 | | using CoreWCF.Channels; |
| | | 8 | | |
| | | 9 | | namespace CoreWCF |
| | | 10 | | { |
| | | 11 | | [Serializable] |
| | | 12 | | public class ProtocolException : CommunicationException |
| | | 13 | | { |
| | 0 | 14 | | public ProtocolException() { } |
| | 2 | 15 | | public ProtocolException(string message) : base(message) { } |
| | 2 | 16 | | public ProtocolException(string message, Exception innerException) : base(message, innerException) { } |
| | 0 | 17 | | protected ProtocolException(SerializationInfo info, StreamingContext context) : base(info, context) { } |
| | | 18 | | |
| | | 19 | | internal static ProtocolException ReceiveShutdownReturnedNonNull(Message message) |
| | | 20 | | { |
| | 0 | 21 | | if (message.IsFault) |
| | | 22 | | { |
| | | 23 | | try |
| | | 24 | | { |
| | 0 | 25 | | MessageFault fault = MessageFault.CreateFault(message, 64 * 1024); |
| | 0 | 26 | | FaultReasonText reason = fault.Reason.GetMatchingTranslation(CultureInfo.CurrentCulture); |
| | 0 | 27 | | string text = SR.Format(SRCommon.ReceiveShutdownReturnedFault, reason.Text); |
| | 0 | 28 | | return new ProtocolException(text); |
| | | 29 | | } |
| | 0 | 30 | | catch (QuotaExceededException) |
| | | 31 | | { |
| | 0 | 32 | | string text = SR.Format(SRCommon.ReceiveShutdownReturnedLargeFault, message.Headers.Action); |
| | 0 | 33 | | return new ProtocolException(text); |
| | | 34 | | } |
| | | 35 | | } |
| | | 36 | | else |
| | | 37 | | { |
| | 0 | 38 | | string text = SR.Format(SRCommon.ReceiveShutdownReturnedMessage, message.Headers.Action); |
| | 0 | 39 | | return new ProtocolException(text); |
| | | 40 | | } |
| | 0 | 41 | | } |
| | | 42 | | } |
| | | 43 | | } |