private static string getTopLevelCauseMessage(Exception t) { Exception topLevelCause = t; while (topLevelCause.InnerException != null) { topLevelCause = topLevelCause.InnerException; } return topLevelCause.Message; }