/// <summary>Converts an IOExcpetion (not subclasses) to SocketException.</summary> /// <remarks> /// Converts an IOExcpetion (not subclasses) to SocketException. /// This is typically done to indicate to upper layers that the error /// was a socket error rather than often more serious exceptions like /// disk errors. /// </remarks> private static IOException IoeToSocketException(IOException ioe) { if (ioe.GetType().Equals(typeof(IOException))) { // "se" could be a new class in stead of SocketException. IOException se = new SocketException("Original Exception : " + ioe); Sharpen.Extensions.InitCause(se, ioe); /* Change the stacktrace so that original trace is not truncated * when printed.*/ se.SetStackTrace(ioe.GetStackTrace()); return(se); } // otherwise just return the same exception. return(ioe); }