コード例 #1
0
 public Exception AsVerbose(Exception exception, EventTraceActivity activity = null)
 {
     return(TraceException <Exception>(exception, TraceEventType.Verbose, activity));
 }
コード例 #2
0
 public Exception AsWarning(Exception exception, EventTraceActivity activity = null)
 {
     return(TraceException <Exception>(exception, TraceEventType.Warning, activity));
 }
コード例 #3
0
 public Exception AsError(Exception exception, EventTraceActivity activity = null)
 {
     return(TraceException <Exception>(exception, TraceEventType.Error, activity));
 }
コード例 #4
0
 public Exception AsInformation(Exception exception, EventTraceActivity activity = null)
 {
     return(TraceException <Exception>(exception, TraceEventType.Information, activity));
 }
コード例 #5
0
        public TException TraceException <TException>(TException exception, TraceEventType level, EventTraceActivity activity = null)
            where TException : Exception
        {
            if (!exception.Data.Contains(this.eventSourceName))
            {
                // Only trace if this is the first time an exception is thrown by this ExceptionTrace/EventSource.
                exception.Data[this.eventSourceName] = this.eventSourceName;

                switch (level)
                {
                case TraceEventType.Critical:
                case TraceEventType.Error:
                    Trace.TraceError("An Exception is being thrown: {0}", GetDetailsForThrownException(exception));
                    ////if (MessagingClientEtwProvider.Provider.IsEnabled(
                    ////        EventLevel.Error,
                    ////        MessagingClientEventSource.Keywords.Client,
                    ////        MessagingClientEventSource.Channels.DebugChannel))
                    ////{
                    ////    MessagingClientEtwProvider.Provider.ThrowingExceptionError(activity, GetDetailsForThrownException(exception));
                    ////}

                    break;

                case TraceEventType.Warning:
                    Trace.TraceWarning("An Exception is being thrown: {0}", GetDetailsForThrownException(exception));
                    ////if (MessagingClientEtwProvider.Provider.IsEnabled(
                    ////        EventLevel.Warning,
                    ////        MessagingClientEventSource.Keywords.Client,
                    ////        MessagingClientEventSource.Channels.DebugChannel))
                    ////{
                    ////    MessagingClientEtwProvider.Provider.ThrowingExceptionWarning(activity, GetDetailsForThrownException(exception));
                    ////}

                    break;

                default:
#if DEBUG
                    ////if (MessagingClientEtwProvider.Provider.IsEnabled(
                    ////        EventLevel.Verbose,
                    ////        MessagingClientEventSource.Keywords.Client,
                    ////        MessagingClientEventSource.Channels.DebugChannel))
                    ////{
                    ////    MessagingClientEtwProvider.Provider.ThrowingExceptionVerbose(activity, GetDetailsForThrownException(exception));
                    ////}
#endif

                    break;
                }
            }

            BreakOnException(exception);
            return(exception);
        }