/// <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 ); }
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()); } }
/// <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); }
private static AdkHttpStatusCode _getErrorCode(AdkHttpStatusCode code) { if ((int)code < 400) { code = AdkHttpStatusCode.ServerError_500_Internal_Server_Error; } return(code); }
private bool ShouldReturnBody(AdkHttpStatusCode code) { if (code == AdkHttpStatusCode.Informational_100_Continue || code == AdkHttpStatusCode.Redirection_304_Not_Modified) { return(false); } else { return(true); } }
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)); }
private bool ShouldReturnBody( AdkHttpStatusCode code ) { if ( code == AdkHttpStatusCode.Informational_100_Continue || code == AdkHttpStatusCode.Redirection_304_Not_Modified ) { return false; } else { return true; } }
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 ); }
protected AdkHttpException( SerializationInfo info, StreamingContext context ) { fCode = (AdkHttpStatusCode) info.GetInt32( "fCode" ); }
private static AdkHttpStatusCode _getErrorCode( AdkHttpStatusCode code ) { if ( (int) code < 400 ) { code = AdkHttpStatusCode.ServerError_500_Internal_Server_Error; } return code; }