/// <summary>
 ///  Constructs an exception with an HttpStatus code, a detailed error message and the cause of the exception
 /// </summary>
 /// <param name="code"></param>
 /// <param name="message"></param>
 /// <param name="innerException">the exception that caused this exception to be raised</param>
 public AdkHttpException( AdkHttpStatusCode code,
                          string message,
                          Exception innerException )
     : base(_constructErrorMessage( code, message ), innerException)
 {
     fCode = _getErrorCode( code );
 }
Esempio n. 2
0
 private string ParseDescription(AdkHttpStatusCode code)
 {
     if (code == AdkHttpStatusCode.Success_200_OK)
     {
         return("OK");
     }
     else
     {
         // Parse off the string before the second underscore
         // and add spaces before caps
         StringBuilder builder         = new StringBuilder();
         int           underscoreCount = 0;
         foreach (char c in code.ToString().ToCharArray())
         {
             if (c == '_')
             {
                 underscoreCount++;
                 continue;
             }
             if (underscoreCount > 1)
             {
                 if (c > 64 && c < 91)
                 {
                     builder.Append(' ');
                 }
                 builder.Append(c);
             }
         }
         return(builder.ToString().TrimStart());
     }
 }
Esempio n. 3
0
 /// <summary>
 ///  Constructs an exception with an HttpStatus code, a detailed error message and the cause of the exception
 /// </summary>
 /// <param name="code"></param>
 /// <param name="message"></param>
 /// <param name="innerException">the exception that caused this exception to be raised</param>
 public AdkHttpException(AdkHttpStatusCode code,
                         string message,
                         Exception innerException)
     : base(_constructErrorMessage(code, message), innerException)
 {
     fCode = _getErrorCode(code);
 }
Esempio n. 4
0
 private static AdkHttpStatusCode _getErrorCode(AdkHttpStatusCode code)
 {
     if ((int)code < 400)
     {
         code = AdkHttpStatusCode.ServerError_500_Internal_Server_Error;
     }
     return(code);
 }
Esempio n. 5
0
 private bool ShouldReturnBody(AdkHttpStatusCode code)
 {
     if (code == AdkHttpStatusCode.Informational_100_Continue ||
         code == AdkHttpStatusCode.Redirection_304_Not_Modified)
     {
         return(false);
     }
     else
     {
         return(true);
     }
 }
Esempio n. 6
0
        private static string _constructErrorMessage(AdkHttpStatusCode code,
                                                     string message)
        {
            AdkHttpStatusCode finalCode = _getErrorCode(code);
            string            enumName  = code.ToString();
            // Find the third underscore and convert the remaining portion of the enum name to a string
            int loc = enumName.IndexOf('_');

            loc      = enumName.IndexOf('_', loc + 1);
            enumName = enumName.Substring(loc + 1);
            enumName = enumName.Replace('_', ' ');
            return(string.Format("HTTP Error {0} {1} : {2}", (int)finalCode, enumName, message));
        }
Esempio n. 7
0
 private bool ShouldReturnBody( AdkHttpStatusCode code )
 {
     if ( code == AdkHttpStatusCode.Informational_100_Continue ||
          code == AdkHttpStatusCode.Redirection_304_Not_Modified ) {
         return false;
     }
     else {
         return true;
     }
 }
Esempio n. 8
0
 private string ParseDescription( AdkHttpStatusCode code )
 {
     if ( code == AdkHttpStatusCode.Success_200_OK ) {
         return "OK";
     }
     else {
         // Parse off the string before the second underscore
         // and add spaces before caps
         StringBuilder builder = new StringBuilder();
         int underscoreCount = 0;
         foreach ( char c in code.ToString().ToCharArray() ) {
             if ( c == '_' ) {
                 underscoreCount++;
                 continue;
             }
             if ( underscoreCount > 1 ) {
                 if ( c > 64 && c < 91 ) {
                     builder.Append( ' ' );
                 }
                 builder.Append( c );
             }
         }
         return builder.ToString().TrimStart();
     }
 }
 private static string _constructErrorMessage( AdkHttpStatusCode code,
                                               string message )
 {
     AdkHttpStatusCode finalCode = _getErrorCode( code );
     string enumName = code.ToString();
     // Find the third underscore and convert the remaining portion of the enum name to a string
     int loc = enumName.IndexOf( '_' );
     loc = enumName.IndexOf( '_', loc + 1 );
     enumName = enumName.Substring( loc + 1 );
     enumName = enumName.Replace( '_', ' ' );
     return string.Format( "HTTP Error {0} {1} : {2}", (int) finalCode, enumName, message );
 }
Esempio n. 10
0
 protected AdkHttpException( SerializationInfo info,
                             StreamingContext context )
 {
     fCode = (AdkHttpStatusCode) info.GetInt32( "fCode" );
 }
Esempio n. 11
0
 private static AdkHttpStatusCode _getErrorCode( AdkHttpStatusCode code )
 {
     if ( (int) code < 400 ) {
         code = AdkHttpStatusCode.ServerError_500_Internal_Server_Error;
     }
     return code;
 }