public static TException LogToCodeTraceSourceBeforeThrow <TException>([NotNull] this TException exception) where TException : Exception { CodeTraceSource.TraceEvent( TraceEventType.Verbose, 0, _assertionFailedMessageWithStack, exception, Environment.StackTrace); return(exception); }
/// <summary>Logs the exception that will be thrown to the <see cref="CodeTraceSource"/>.</summary> /// <typeparam name="TException">The type of the exception.</typeparam> /// <param name="exception">The exception.</param> /// <returns>The original exception.</returns> internal static TException LogToCodeTraceSourceBeforeThrow <TException>(this TException exception) where TException : Exception { var sb = new StringBuilder(); exception.ToDiagnosticString(sb); if (exception.StackTrace == null) { sb.Append(new StackTrace()); } CodeTraceSource.TraceEvent(TraceEventType.Error, 0, sb.ToString()); return(exception); }
/// <summary>Logs the catched exception to the <see cref="CodeTraceSource"/>.</summary> /// <typeparam name="TException">The type of the exception.</typeparam> /// <param name="exception">The exception.</param> /// <returns>The original exception.</returns> internal static TException LogToCodeTraceSourceCatched <TException>(this TException exception) where TException : Exception { var sb = new StringBuilder(); sb.Append("Swallowed: "); exception.ToDiagnosticString(sb); if (exception.StackTrace == null) { sb.Append(new StackTrace()); } CodeTraceSource.TraceEvent(TraceEventType.Warning, 0, sb.ToString()); return(exception); }
public static TException LogToCodeTraceSourceOnCatch <TException>([NotNull] this TException exception, bool safe) where TException : Exception { if (safe) { CodeTraceSource.TraceEvent( TraceEventType.Verbose, 0, _exceptionCaughtMessage, exception); } else { CodeTraceSource.TraceEvent( TraceEventType.Warning, 0, _exceptionSwallowedMessage, exception); } return(exception); }