예제 #1
0
 protected Exception GetException(Exception e)
 {
     e = HttpWebRequest.FlattenException(e);
     if (e is WebException)
     {
         return(e);
     }
     if (Operation.Aborted || e is OperationCanceledException || e is ObjectDisposedException)
     {
         return(HttpWebRequest.CreateRequestAbortedException());
     }
     return(e);
 }
예제 #2
0
        WebException GetReadException(WebExceptionStatus status, Exception error, string where)
        {
            error = GetException(error);
            string msg = $"Error getting response stream ({where}): {status}";

            if (error == null)
            {
                return(new WebException($"Error getting response stream ({where}): {status}", status));
            }
            if (error is WebException wexc)
            {
                return(wexc);
            }
            if (Operation.Aborted || error is OperationCanceledException || error is ObjectDisposedException)
            {
                return(HttpWebRequest.CreateRequestAbortedException());
            }
            return(new WebException($"Error getting response stream ({where}): {status} {error.Message}", status,
                                    WebExceptionInternalStatus.RequestFatal, error));
        }