public void ExceptionDataTest() { var ex = new Exception(); ex.Data.Add("data2", "data container"); Assert.AreEqual(true, ex.GetExceptionText(includeData: true).Contains("data2")); Assert.AreEqual(true, ex.GetExceptionText(includeData: true).Contains("data container")); }
/// <summary> /// Add log message from exception with catcher information /// </summary> /// <param name="ex">Exception to log</param> /// <param name="whereCathed">Cather information (e.g. function name)</param> public static void Add(Exception ex, string whereCathed) { Add(string.Format(WhereCatchedFormat, whereCathed, ex.GetExceptionText())); }
/// <summary> /// Add log message from exception /// </summary> /// <param name="ex">Exception to log</param> public static void Add(Exception ex) { Add(ex.GetExceptionText()); }
/// <summary> /// Add log message from exception to session /// </summary> /// <param name="session">Session identifier</param> /// <param name="ex">Exception to log</param> public static void Add(Guid session, Exception ex) { Add(session, ex.GetExceptionText()); }
private string GetExceptionText(string whereCatched, Exception ex) { return ex.GetExceptionText($"{GetType().Name}.{whereCatched}()" #if !DEBUG , clearText: true, includeData: false, includeStackTrace: false #endif ); }
/// <summary> /// Add log message from exception with catcher information /// </summary> /// <param name="ex">Exception to log</param> /// <param name="whereCathed">Cather information (e.g. function name)</param> public static void Add(Exception ex, string whereCathed = null) { Add(ex.GetExceptionText(), whereCathed); }