internal static Exception CloseNeighborIfKnownException(PeerNeighborManager neighborManager, Exception exception, IPeerNeighbor peer) { try { if (exception is ObjectDisposedException) { return(null); } if (((exception is CommunicationException) && !(exception.InnerException is QuotaExceededException)) || (((exception is TimeoutException) || (exception is InvalidOperationException)) || (exception is MessageSecurityException))) { neighborManager.CloseNeighbor(peer, PeerCloseReason.InternalFailure, PeerCloseInitiator.LocalNode, exception); return(null); } return(exception); } catch (Exception exception2) { if (Fx.IsFatal(exception2)) { throw; } System.ServiceModel.DiagnosticUtility.ExceptionUtility.TraceHandledException(exception2, TraceEventType.Information); return(exception2); } }
// Guaranteed not to throw anything other than fatal exceptions static internal Exception CloseNeighborIfKnownException(PeerNeighborManager neighborManager, Exception exception, IPeerNeighbor peer) { try { //ignore this one since the channel is already closed. if (exception is ObjectDisposedException) { return(null); } else if ( (exception is CommunicationException && !(exception.InnerException is QuotaExceededException)) || (exception is TimeoutException) || (exception is InvalidOperationException) || (exception is MessageSecurityException) ) { //is this the right close reason? neighborManager.CloseNeighbor(peer, PeerCloseReason.InternalFailure, PeerCloseInitiator.LocalNode, exception); return(null); } else { //exception that we dont know or cant act on. //we will throw this exception to the user. return(exception); } } catch (Exception e) { if (Fx.IsFatal(e)) { throw; } DiagnosticUtility.TraceHandledException(e, TraceEventType.Information); return(e); } }
void IPeerMaintainer.CloseNeighbor(IPeerNeighbor neighbor, PeerCloseReason closeReason) { neighborManager.CloseNeighbor(neighbor, closeReason, PeerCloseInitiator.LocalNode); }