示例#1
0
 public WebException(string message, System.Net.WebExceptionStatus status)
 {
 }
示例#2
0
        internal static void ThrowException(FtpWebResponse response)
        {
            System.Net.WebExceptionStatus status = System.Net.WebExceptionStatus.Success;

            ERROR_INTERNET error   = (ERROR_INTERNET)Marshal.GetLastWin32Error();
            string         message = string.Empty;

            if (error == 0)
            {
                return;
            }

            ERROR_INTERNET lrError;
            string         lastResponse = Ftp.GetLastResponseInfo(out lrError);

            if (string.IsNullOrEmpty(lastResponse))
            {
                message = "Unable to connect to the remote server";
            }
            else
            {
                message = "Server response: " + lastResponse;
            }

            //try to get most relevant webexceptionstatus
            switch (error)
            {
            case ERROR_INTERNET.CONNECTION_ABORTED:
            case ERROR_INTERNET.CONNECTION_RESET:
            case ERROR_INTERNET.DISCONNECTED:
            case ERROR_INTERNET.FTP_DROPPED:
                status = System.Net.WebExceptionStatus.ConnectionClosed;
                break;

            case ERROR_INTERNET.CANNOT_CONNECT:
            case ERROR_INTERNET.SERVER_UNREACHABLE:
            case ERROR_INTERNET.FTP_NO_PASSIVE_MODE:
                status = System.Net.WebExceptionStatus.ConnectFailure;
                break;

            case ERROR_INTERNET.TIMEOUT:
                status = System.Net.WebExceptionStatus.Timeout;
                break;

            case ERROR_INTERNET.SECURITY_CHANNEL_ERROR:
                status = System.Net.WebExceptionStatus.SecureChannelFailure;
                break;

            case ERROR_INTERNET.NAME_NOT_RESOLVED:
                status = System.Net.WebExceptionStatus.NameResolutionFailure;
                break;

            default:
                /*case ERROR_INTERNET.INCORRECT_PASSWORD:
                 * case ERROR_INTERNET.INCORRECT_USER_NAME:
                 * case ERROR_INTERNET.FTP_TRANSFER_IN_PROGRESS:
                 * case ERROR_INTERNET.LOGIN_FAILURE:*/
                status = System.Net.WebExceptionStatus.ProtocolError;
                break;
            }

            throw new System.Net.WebException(message, InTheHand.ComponentModel.Win32ExceptionInTheHand.Create((int)error), status, response);
        }
示例#3
0
 public WebException(string message, System.Exception innerException, System.Net.WebExceptionStatus status, System.Net.WebResponse response)
 {
 }
示例#4
0
 private static void SetStatus(this object connection, System.Net.WebExceptionStatus status)
 {
     (_status ?? (_status = connection.GetType().GetField("status", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance))).SetValue(connection, status);
 }