private string BuildApiErrorMessage(DhcpErrors error) { var errorType = typeof(DhcpErrors).GetMember(error.ToString()); if (errorType.Length != 0) { var errorAttribute = errorType[0].GetCustomAttributes(typeof(DhcpErrorDescriptionAttribute), false); if (errorAttribute.Length != 0) { return(((DhcpErrorDescriptionAttribute)errorAttribute[0]).Description); } } return("Unknown Error"); }
private string BuildMessage(string apiFunction, string additionalMessage, DhcpErrors error, string apiErrorMessage) { var builder = new StringBuilder(); if (apiFunction != null) { builder.Append("An error occurred calling '").Append(apiFunction).Append("'. "); } if (additionalMessage != null) { builder.Append(additionalMessage).Append(". "); } builder.Append(apiErrorMessage).Append(" [").Append(error.ToString()).Append(' ').Append((uint)error).Append(']'); return(builder.ToString()); }