internal static void ThrowAndCatch(Exception e) { ErrorBehavior.ThrowAndCatch(e, null); }
private void OnConnectionModeKnownCore(Microsoft.ServiceBus.Channels.ConnectionModeReader modeReader, bool isCached) { Microsoft.ServiceBus.Channels.FramingMode connectionMode; lock (this.ThisLock) { if (!this.isClosed) { this.connectionReaders.Remove(modeReader); } else { return; } } bool flag = true; try { try { try { connectionMode = modeReader.GetConnectionMode(); } catch (CommunicationException communicationException1) { CommunicationException communicationException = communicationException1; TraceEventType exceptionEventType = modeReader.Connection.ExceptionEventType; if (Microsoft.ServiceBus.Diagnostics.DiagnosticUtility.ShouldTrace(exceptionEventType)) { Microsoft.ServiceBus.Diagnostics.DiagnosticUtility.ExceptionUtility.TraceHandledException(communicationException, exceptionEventType); } return; } catch (TimeoutException timeoutException1) { TimeoutException timeoutException = timeoutException1; if (!isCached) { string channelInitializationTimeout = Resources.ChannelInitializationTimeout; object[] objArray = new object[] { this.channelInitializationTimeout }; timeoutException = new TimeoutException(Microsoft.ServiceBus.SR.GetString(channelInitializationTimeout, objArray), timeoutException); ErrorBehavior.ThrowAndCatch(timeoutException); } TraceEventType traceEventType = modeReader.Connection.ExceptionEventType; if (Microsoft.ServiceBus.Diagnostics.DiagnosticUtility.ShouldTrace(traceEventType)) { Microsoft.ServiceBus.Diagnostics.DiagnosticUtility.ExceptionUtility.TraceHandledException(timeoutException, traceEventType); } return; } switch (connectionMode) { case Microsoft.ServiceBus.Channels.FramingMode.Singleton: { this.OnSingletonConnection(modeReader.Connection, modeReader.ConnectionDequeuedCallback, modeReader.StreamPosition, modeReader.BufferOffset, modeReader.BufferSize, modeReader.GetRemainingTimeout()); break; } case Microsoft.ServiceBus.Channels.FramingMode.Duplex: { this.OnDuplexConnection(modeReader.Connection, modeReader.ConnectionDequeuedCallback, modeReader.StreamPosition, modeReader.BufferOffset, modeReader.BufferSize, modeReader.GetRemainingTimeout()); break; } default: { string framingModeNotSupported = Resources.FramingModeNotSupported; object[] objArray1 = new object[] { connectionMode }; Exception invalidDataException = new InvalidDataException(Microsoft.ServiceBus.SR.GetString(framingModeNotSupported, objArray1)); Exception protocolException = new ProtocolException(invalidDataException.Message, invalidDataException); Microsoft.ServiceBus.Channels.FramingEncodingString.AddFaultString(protocolException, "http://schemas.microsoft.com/ws/2006/05/framing/faults/UnsupportedMode"); ErrorBehavior.ThrowAndCatch(protocolException); return; } } flag = false; } catch (Exception exception1) { Exception exception = exception1; if (Fx.IsFatal(exception)) { throw; } TraceEventType exceptionEventType1 = modeReader.Connection.ExceptionEventType; if (Microsoft.ServiceBus.Diagnostics.DiagnosticUtility.ShouldTrace(exceptionEventType1)) { Microsoft.ServiceBus.Diagnostics.DiagnosticUtility.ExceptionUtility.TraceHandledException(exception, exceptionEventType1); } } } finally { if (flag) { modeReader.Dispose(); } } }