The Labs \ Source Viewer \ SSCLI \ System.Net \ WebExceptionStatus

  1. //------------------------------------------------------------------------------
  2. // <copyright file="WebExceptionStatus.cs" company="Microsoft">
  3. //
  4. // Copyright (c) 2006 Microsoft Corporation. All rights reserved.
  5. //
  6. // The use and distribution terms for this software are contained in the file
  7. // named license.txt, which can be found in the root of this distribution.
  8. // By using this software in any fashion, you are agreeing to be bound by the
  9. // terms of this license.
  10. //
  11. // You must not remove this notice, or any other, from this software.
  12. //
  13. // </copyright>
  14. //------------------------------------------------------------------------------
  15. namespace System.Net
  16. {
  17.    
  18.     /// <devdoc>
  19.     /// <para>
  20.     /// Specifies the status of a network request.
  21.     /// </para>
  22.     /// </devdoc>
  23.     public enum WebExceptionStatus
  24.     {
  25.         /// <devdoc>
  26.         /// <para>
  27.         /// No error was encountered.
  28.         /// </para>
  29.         /// </devdoc>
  30.         Success = 0,
  31.        
  32.         /// <devdoc>
  33.         /// <para>
  34.         /// The name resolver service could not resolve the host name.
  35.         /// </para>
  36.         /// </devdoc>
  37.         NameResolutionFailure = 1,
  38.        
  39.         /// <devdoc>
  40.         /// <para>
  41.         /// The remote service point could not be contacted at the transport level.
  42.         /// </para>
  43.         /// </devdoc>
  44.         ConnectFailure = 2,
  45.        
  46.         /// <devdoc>
  47.         /// <para>
  48.         /// A complete response was not received from the remote server.
  49.         /// </para>
  50.         /// </devdoc>
  51.         ReceiveFailure = 3,
  52.        
  53.         /// <devdoc>
  54.         /// <para>
  55.         /// A complete request could not be sent to the remote server.
  56.         /// </para>
  57.         /// </devdoc>
  58.         SendFailure = 4,
  59.        
  60.         /// <internalonly/>
  61.         /// <devdoc>
  62.         /// </devdoc>
  63.         PipelineFailure = 5,
  64.        
  65.         /// <devdoc>
  66.         /// <para>
  67.         /// The request was cancelled.
  68.         /// </para>
  69.         /// </devdoc>
  70.         RequestCanceled = 6,
  71.        
  72.         /// <devdoc>
  73.         /// <para>
  74.         /// The response received from the server was complete but indicated a
  75.         /// protocol-level error. For example, an HTTP protocol error such as 401 Access
  76.         /// Denied would use this status.
  77.         /// </para>
  78.         /// </devdoc>
  79.         ProtocolError = 7,
  80.        
  81.         /// <devdoc>
  82.         /// <para>
  83.         /// The connection was prematurely closed.
  84.         /// </para>
  85.         /// </devdoc>
  86.         ConnectionClosed = 8,
  87.        
  88.         /// <devdoc>
  89.         /// <para>
  90.         /// A server certificate could not be validated.
  91.         /// </para>
  92.         /// </devdoc>
  93.         TrustFailure = 9,
  94.        
  95.         /// <devdoc>
  96.         /// <para>
  97.         /// An error occurred in a secure channel link.
  98.         /// </para>
  99.         /// </devdoc>
  100.         SecureChannelFailure = 10,
  101.        
  102.         /// <devdoc>
  103.         /// <para>[To be supplied.]</para>
  104.         /// </devdoc>
  105.         ServerProtocolViolation = 11,
  106.        
  107.         /// <devdoc>
  108.         /// <para>[To be supplied.]</para>
  109.         /// </devdoc>
  110.         KeepAliveFailure = 12,
  111.        
  112.         /// <devdoc>
  113.         /// <para>[To be supplied.]</para>
  114.         /// </devdoc>
  115.         Pending = 13,
  116.        
  117.         /// <devdoc>
  118.         /// <para>[To be supplied.]</para>
  119.         /// </devdoc>
  120.         Timeout = 14,
  121.        
  122.         /// <devdoc>
  123.         /// <para>
  124.         /// Similar to NameResolution Failure, but for proxy failures.
  125.         /// </para>
  126.         /// </devdoc>
  127.         ProxyNameResolutionFailure = 15,
  128.        
  129.         /// <devdoc>
  130.         /// <para>[To be supplied.]</para>
  131.         /// </devdoc>
  132.         UnknownError = 16,
  133.        
  134.         /// <devdoc>
  135.         /// <para>
  136.         /// Sending the request to the server or receiving the response from it,
  137.         /// required handling a message that exceeded the specified limit.
  138.         /// </para>
  139.         /// </devdoc>
  140.         MessageLengthLimitExceeded = 17,
  141.        
  142.         //
  143.         // A request could be served from Cache but was not found and effective CachePolicy=CacheOnly
  144.         //
  145.         CacheEntryNotFound = 18,
  146.        
  147.         //
  148.         // A request is not suitable for caching and effective CachePolicy=CacheOnly
  149.         //
  150.         RequestProhibitedByCachePolicy = 19,
  151.        
  152.         //
  153.         // The proxy script (or other proxy logic) declined to provide proxy info, effectively blocking the request.
  154.         //
  155.         RequestProhibitedByProxy = 20
  156.        
  157.         // !! If new values are added, increase the size of the s_Mapping array below to the largest value + 1.
  158.     }
  159.     // enum WebExceptionStatus
  160.     // Mapping from enum value to error message.
  161.     static internal class WebExceptionMapping
  162.     {
  163.         private static readonly string[] s_Mapping = new string[21];
  164.        
  165.         static internal string GetWebStatusString(WebExceptionStatus status)
  166.         {
  167.             int statusInt = (int)status;
  168.             if (statusInt >= s_Mapping.Length || statusInt < 0) {
  169.                 throw new InternalException();
  170.             }
  171.            
  172.             string message = s_Mapping[statusInt];
  173.             if (message == null) {
  174.                 message = "net_webstatus_" + status.ToString();
  175.                 s_Mapping[statusInt] = message;
  176.             }
  177.             return message;
  178.         }
  179.     }
  180. }
  181. // namespace System.Net

Developer Fusion