如何获取 innerException 内部错误信息
String innerMessage = (ex.InnerException != null)
? ex.InnerException.Message
: "";
这断代码看上去可以解决问题,但是党innerException中还有innerException的得时候就无效了。
所以有了下面得扩展方法,使用递归获取innerException,完美解决
public static class ExceptionExtensions
{
public static Exception GetOriginalException(this Exception ex)
{
if (ex.InnerException == null) return ex;
return ex.InnerException.GetOriginalException();
}
}
参考:http://stackoverflow.com/questions/1456563/best-way-to-check-for-inner-exception
参考:https://www.cnblogs.com/miralce/archive/2015/10/19/4892193.html

浙公网安备 33010602011771号