/// <summary> /// 获取错误代码 /// 参见:http://msdn.microsoft.com/zh-cn/library/bb762164(v=vs.85).aspx /// </summary> /// <param name="n"></param> /// <returns></returns> public static string GetErrorString(int n) { if (ErrorMap == null) { InitErrorMap(); } string code = n.ToString("X").ToUpper(); string message = null; if (ErrorMap.TryGetValue(code, out message)) { return(message); } return(code); }
private static string GetErrorDescription(HRESULT hr) { if (_detailedErrorMap.TryGetValue(hr, out string value)) { return($"Unknown exception occured with HRESULT {hr:X8} - \"" + $"{value}\""); } else if (ErrorMap.TryGetValue(hr, out value)) { return($"Unknown exception occured with HRESULT {hr:X8} - \"" + $"{value}\""); } else { return($"Unknown exception occured with HRESULT {hr:X8}"); } }