如何获取 innerException 内部错误信息
String innerMessage = (ex.InnerException != null) ? ex.InnerException.Message : "";
所以有了下面得扩展方法,使用递归获取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