src/VisualStudio/Core/Def/Implementation/Watson/WatsonReporter.cs
/// <summary>
/// Report Non-Fatal Watson for a given unhandled exception.
/// </summary>
/// <param name="exception">Exception that triggered this non-fatal error</param>
Report Non-Fatal Watson for a given unhandled exception.
Report Non - Fatal Watson for a given unhandled exception .
public static void ReportNonFatal(Exception exception)
        {
            if (exception is OutOfMemoryException)
            {
                FailFast.OnFatalException(exception);
            }
            var emptyCallstack = exception.SetCallstackIfEmpty();
            var currentProcess = Process.GetCurrentProcess();
            s_logger?.TraceEvent(TraceEventType.Error, 1, $"[{currentProcess.ProcessName}:{currentProcess.Id}] Unexpected exception: {exception}");
            var session = s_telemetrySession;
            if (session == null)
            {
                return;
            }
            var faultEvent = new FaultEvent(
                eventName: FunctionId.NonFatalWatson.GetEventName(),
                description: GetDescription(exception),
                FaultSeverity.Diagnostic,
                exceptionObject: exception,
                gatherEventDetails: faultUtility =>
                {
                    if (faultUtility is FaultEvent { IsIncludedInWatsonSample: true })
                    {
                        foreach (var path in CollectServiceHubLogFilePaths())
                        {
                            faultUtility.AddFile(path);
                        }
                    }
                    return 0;
                });
            faultEvent.SetExtraParameters(exception, emptyCallstack);
            session.PostEvent(faultEvent);
        }
public static void ReportNonFatal ( Exception exception ) { if ( exception is OutOfMemoryException ) { FailFast . OnFatalException ( exception ) ; } var emptyCallstack = exception . SetCallstackIfEmpty ( ) ; var currentProcess = Process . GetCurrentProcess ( ) ; s_logger ? . TraceEvent ( TraceEventType . Error , 1 , $" [ { currentProcess . ProcessName } : { currentProcess . Id } ] Unexpected exception:  { exception } " ) ; var session = s_telemetrySession ; if ( session == null ) { return ; } var faultEvent = new FaultEvent ( eventName : FunctionId . NonFatalWatson . GetEventName ( ) , description : GetDescription ( exception ) , FaultSeverity . Diagnostic , exceptionObject : exception , gatherEventDetails : faultUtility => { if ( faultUtility is FaultEvent { IsIncludedInWatsonSample : true } ) { foreach ( var path in CollectServiceHubLogFilePaths ( ) ) { faultUtility . AddFile ( path ) ; } } return 0 ; } ) ; faultEvent . SetExtraParameters ( exception , emptyCallstack ) ; session . PostEvent ( faultEvent ) ; }
Report Non-Fatal Watson for a given unhandled exception.
Report Non - Fatal Watson for a given unhandled exception .
// write the exception to a log file: // add ServiceHub log files: // Returning "0" signals that, if sampled, we should send data to Watson.  // Any other value will cancel the Watson report. We never want to trigger a process dump manually,  // we'll let TargetedNotifications determine if a dump should be collected. // See https://aka.ms/roslynnfwdocs for more details // add extra bucket parameters to bucket better in NFW // we do it here so that it gets bucketted better in both // watson and telemetry. 
exception
Exception
Exception that triggered this non-fatal error
Exception that triggered this non - fatal error