Exemplo n.º 1
0
        public void LogFault(Exception ex, string description, bool dumpProcess)
        {
            var session = _session.Value;

            // No session is not a fatal error
            if (session == null)
            {
                return;
            }

            // Never send events when users have not opted in.
            if (!session.IsOptedIn)
            {
                return;
            }

            var fault = new FaultEvent(
                EventPrefix + "UnhandledException",
                !string.IsNullOrEmpty(description) ? description : "Unhandled exception in Python extension.",
                ex
                );

            if (dumpProcess)
            {
                fault.AddProcessDump(Process.GetCurrentProcess().Id);
                fault.IsIncludedInWatsonSample = true;
            }
            else
            {
                fault.IsIncludedInWatsonSample = false;
            }

            session.PostEvent(fault);
        }
        // pretty print a fault statement to the console
        internal virtual void dumpFaultLine(FaultEvent e)
        {
            System.Text.StringBuilder sb = new System.Text.StringBuilder();

            // use a slightly different format for ConsoleErrorFaults
            if (e is ConsoleErrorFault)
            {
                sb.Append(TextHelper.GetString("Info.LinePrefixWhenDisplayingConsoleError"));                 //$NON-NLS-1$
                sb.Append(' ');
                sb.Append(e.information);
            }
            else
            {
                String name = e.name();
                sb.Append(TextHelper.GetString("Info.LinePrefixWhenDisplayingFault")); //$NON-NLS-1$
                sb.Append(' ');
                sb.Append(name);
                if (e.information != null && e.information.Length > 0)
                {
                    sb.Append(TextHelper.GetString("Info.InformationAboutFault")); //$NON-NLS-1$
                    sb.Append(e.information);
                }
            }
            TraceManager.AddAsync(sb.ToString(), 3);
        }
Exemplo n.º 3
0
        // assign the object o, the value v; returns Boolean true if worked, false if failed
        public virtual Object assign(Object o, Object v)
        {
            bool worked = false;

            try
            {
                Variable var = resolveToVariable(o);
                if (var == null)
                {
                    throw new NoSuchVariableException(m_current);
                }
                // set the value, for the case of a variable that does not exist it will not have a type
                // so we try to glean one from v.
                int        type       = determineType(var, v);
                FaultEvent faultEvent = var.setValue(type, v.ToString());
                if (faultEvent != null)
                {
                    throw new PlayerFaultException(faultEvent);
                }
                worked = true;
            }
            catch (PlayerDebugException)
            {
                worked = false;
            }
            return(worked);
        }
Exemplo n.º 4
0
        async Task GenerateFault <T>(ConsumeContext <T> context, Exception exception)
            where T : class
        {
            Fault <T> fault = new FaultEvent <T>(context.Message, context.MessageId, HostMetadataCache.Host, exception);

            IPipe <SendContext <Fault <T> > > faultPipe = Pipe.Execute <SendContext <Fault <T> > >(x =>
            {
                x.TransferConsumeContextHeaders(context);

                x.CorrelationId = context.CorrelationId;
                x.RequestId     = context.RequestId;
            });

            var destinationAddress = FaultAddress ?? ResponseAddress;

            if (destinationAddress != null)
            {
                var endpoint = await GetSendEndpoint(destinationAddress).ConfigureAwait(false);

                await endpoint.Send(fault, faultPipe, CancellationToken).ConfigureAwait(false);
            }
            else
            {
                await Publish(fault, faultPipe, CancellationToken).ConfigureAwait(false);
            }
        }
Exemplo n.º 5
0
        public static async Task PostFaultAsync(Exception e, string callerClassName, [CallerMemberName] string callerMemberName = null, IDictionary <string, object> extraProperties = null)
        {
            if (e == null)
            {
                throw new ArgumentNullException(nameof(e));
            }

            var caller      = $"{callerClassName}.{callerMemberName}";
            var description = $"{e.GetType().Name} - {e.Message}";

            await NuGetUIThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync();

            var fault = new FaultEvent(VSTelemetrySession.VSEventNamePrefix + "Fault", description, FaultSeverity.General, e, gatherEventDetails: null);

            fault.Properties[$"{VSTelemetrySession.VSPropertyNamePrefix}Fault.Caller"] = caller;
            if (extraProperties != null)
            {
                foreach (var kvp in extraProperties)
                {
                    fault.Properties[VSTelemetrySession.VSEventNamePrefix + kvp.Key] = kvp.Value;
                }
            }

            TelemetryService.DefaultSession.PostEvent(fault);

            if (await IsShellAvailable.GetValueAsync())
            {
                ActivityLog.TryLogError(caller, description);
            }
        }
Exemplo n.º 6
0
        async Task GenerateFault <T>(ConsumeContext <T> context, Exception exception)
            where T : class
        {
            Fault <T> fault = new FaultEvent <T>(context.Message, context.MessageId, HostMetadataCache.Host, exception);

            IPipe <SendContext <Fault <T> > > faultPipe = Pipe.Execute <SendContext <Fault <T> > >(x =>
            {
                x.SourceAddress = ReceiveContext.InputAddress;
                x.CorrelationId = CorrelationId;
                x.RequestId     = RequestId;

                foreach (KeyValuePair <string, object> header in Headers.GetAll())
                {
                    x.Headers.Set(header.Key, header.Value);
                }
            });

            if (FaultAddress != null)
            {
                var endpoint = await GetSendEndpoint(FaultAddress).ConfigureAwait(false);

                await endpoint.Send(fault, faultPipe, CancellationToken).ConfigureAwait(false);
            }
            else if (ResponseAddress != null)
            {
                var endpoint = await GetSendEndpoint(ResponseAddress).ConfigureAwait(false);

                await endpoint.Send(fault, faultPipe, CancellationToken).ConfigureAwait(false);
            }
            else
            {
                await _publishEndpoint.Value.Publish(fault, faultPipe, CancellationToken).ConfigureAwait(false);
            }
        }
Exemplo n.º 7
0
        async Task GenerateFault <T>(T message, Exception exception)
            where T : class
        {
            Fault <T> fault = new FaultEvent <T>(message, HostMetadataCache.Host, exception);

            IPipe <SendContext <Fault <T> > > faultPipe = Pipe.New <SendContext <Fault <T> > >(x => x.UseExecute(v =>
            {
                v.SourceAddress = ReceiveContext.InputAddress;
                v.CorrelationId = CorrelationId;
                v.RequestId     = RequestId;

                foreach (var header in Headers.GetAll())
                {
                    v.Headers.Set(header.Key, header.Value);
                }
            }));

            if (ResponseAddress != null)
            {
                ISendEndpoint endpoint = await GetSendEndpoint(ResponseAddress).ConfigureAwait(false);

                await endpoint.Send(fault, faultPipe, CancellationToken).ConfigureAwait(false);
            }
            else
            {
                await _publishEndpoint.Publish(fault, faultPipe, CancellationToken).ConfigureAwait(false);
            }
        }
Exemplo n.º 8
0
 private void OnFault(FaultEvent fault)
 {
     if (TestScenario != null)
     {
         TestScenario.Events.Enqueue(fault);
         Console.WriteLine("Got fault event: {0}", fault);
     }
 }
Exemplo n.º 9
0
        public static void ReportNonFatal(Exception exception)
        {
            if (exception is OutOfMemoryException)
            {
                FailFast.OnFatalException(exception);
            }

            if (!s_report)
            {
                return;
            }

            var emptyCallstack = exception.SetCallstackIfEmpty();
            var currentProcess = Process.GetCurrentProcess();

            // write the exception to a log file:
            s_logger?.TraceEvent(TraceEventType.Error, 1, $"[{currentProcess.ProcessName}:{currentProcess.Id}] Unexpected exception: {exception}");

            var session = s_telemetrySession;

            if (session == null)
            {
                return;
            }

            var logFilePaths = CaptureLogFiles();

            var faultEvent = new FaultEvent(
                eventName: FunctionId.NonFatalWatson.GetEventName(),
                description: "Roslyn NonFatal Watson",
                FaultSeverity.Diagnostic,
                exceptionObject: exception,
                gatherEventDetails: faultUtility =>
            {
                // add current process dump
                faultUtility.AddProcessDump(currentProcess.Id);

                // add ServiceHub log files:
                foreach (var path in logFilePaths)
                {
                    faultUtility.AddFile(path);
                }

                // Returning "0" signals that we should send data to Watson; any other value will cancel the Watson report.
                return(0);
            });

            // add extra bucket parameters to bucket better in NFW
            // we do it here so that it gets bucketted better in both
            // watson and telemetry.
            faultEvent.SetExtraParameters(exception, emptyCallstack);

            session.PostEvent(faultEvent);
        }
Exemplo n.º 10
0
        protected virtual async Task GenerateFault <T>(ConsumeContext <T> context, Exception exception)
            where T : class
        {
            Fault <T> fault = new FaultEvent <T>(context.Message, context.MessageId, HostMetadataCache.Host, exception, context.SupportedMessageTypes.ToArray());

            var faultPipe = new FaultPipe <T>(context);

            var faultEndpoint = await this.GetFaultEndpoint <T>().ConfigureAwait(false);

            await faultEndpoint.Send(fault, faultPipe, CancellationToken).ConfigureAwait(false);
        }
Exemplo n.º 11
0
        public void PostFault(TelemetryIdentifier telemetryIdentifier, string description, Exception exception, IEnumerable <DataPoint> properties)
        {
            //IL_0022: Unknown result type (might be due to invalid IL or missing references)
            //IL_0028: Expected O, but got Unknown
            if (telemetryIdentifier == null)
            {
                throw new ArgumentNullException("telemetryIdentifier");
            }
            FaultEvent val = (FaultEvent)(object)new FaultEvent(telemetryIdentifier.Value, description, exception, (Func <IFaultUtility, int>)SendFaultToWatson);

            DataPointCollection.AddCollectionToDictionary(properties, ((TelemetryEvent)val).Properties);
            telemetryRecorder.RecordEvent((TelemetryEvent)(object)val);
        }
        public bool PostFault(string eventName, Exception exceptionObject)
        {
            Requires.NotNullOrEmpty(eventName, nameof(eventName));
            Requires.NotNull(exceptionObject, nameof(exceptionObject));

            var faultEvent = new FaultEvent(eventName,
                                            description: null,
                                            exceptionObject);

            PostTelemetryEvent(faultEvent);

            return(true);
        }
Exemplo n.º 13
0
        private int GetADCRegisterData()
        {
            //Shift MSB to the left 8 bits)
            int RTDVala = GetRegister(0x01) << 8;
            int RTDValb = GetRegister(0x02);

            if ((GetRegister(0x02) & 0x01) > 0)
            {
                FaultEvent?.Invoke(this, GetRegister((byte)Register.FLT_STATUS));
            }
            //FaultEvent(this, );
            //Merge bytes
            return(RTDVala | RTDValb);
        }
Exemplo n.º 14
0
        /// <summary>
        /// Report Non-Fatal Watson
        /// </summary>
        /// <param name="description">any description you want to save with this watson report</param>
        /// <param name="exception">Exception that triggered this non-fatal error</param>
        /// <param name="callback">Callback to include extra data with the NFW. Note that we always collect
        /// a dump of the current process, but this can be used to add further information or files to the
        /// CAB.</param>
        /// <param name="severity">indicate <see cref="WatsonSeverity"/> of NFW</param>
        public static void Report(string description, Exception exception, Func <IFaultUtility, int> callback, WatsonSeverity severity = WatsonSeverity.Default)
        {
            var critical       = severity == WatsonSeverity.Critical;
            var emptyCallstack = exception.SetCallstackIfEmpty();

            // if given exception is non recoverable exception,
            // crash instead of NFW
            if (IsNonRecoverableException(exception))
            {
                CodeAnalysis.FailFast.OnFatalException(exception);
            }

            if (!exception.ShouldReport())
            {
                return;
            }

            if (RoslynServices.SessionOpt == null)
            {
                return;
            }

            // in OOP, we don't fire Critical NFW, rather we fire General which is 1 level higher than Diagnostic
            // and we keep fire NFW even after critical report.
            // critical NFW regarding OOP from VS side will let us to prioritize NFW to fix, and NFW from here should provide
            // extra dump/info to take a look.
            // whenever there is an exception in OOP, we fire NFW in both VS and OOP side. VS will report it as critical NFW
            // and OOP will fire normal NFW. we only mark VS side critical since we don't want to double report same issue
            // and don't want to shutdown NFW in OOP
            // one can correlate NFW from VS and OOP through remote callstack in VS NFW
            var faultEvent = new FaultEvent(
                eventName: FunctionId.NonFatalWatson.GetEventName(),
                description: description,
                critical ? FaultSeverity.General : FaultSeverity.Diagnostic,
                exceptionObject: exception,
                gatherEventDetails: arg =>
            {
                // always add current processes dump
                arg.AddProcessDump(System.Diagnostics.Process.GetCurrentProcess().Id);

                return(callback(arg));
            });

            // add extra bucket parameters to bucket better in NFW
            // we do it here so that it gets bucketted better in both
            // watson and telemetry.
            faultEvent.SetExtraParameters(exception, emptyCallstack);

            RoslynServices.SessionOpt.PostEvent(faultEvent);
        }
Exemplo n.º 15
0
        public void PostFault(TelemetryIdentifier telemetryIdentifier, string description, Exception exception)
        {
            //IL_0022: Unknown result type (might be due to invalid IL or missing references)
            //IL_0028: Expected O, but got Unknown
            //IL_0037: Unknown result type (might be due to invalid IL or missing references)
            //IL_003c: Unknown result type (might be due to invalid IL or missing references)
            if (telemetryIdentifier == null)
            {
                throw new ArgumentNullException("telemetryIdentifier");
            }
            FaultEvent val = (FaultEvent)(object)new FaultEvent(telemetryIdentifier.Value, description, exception, (Func <IFaultUtility, int>)SendFaultToWatson);

            EndEvent.Correlate(((TelemetryEvent)val).Correlation);
            TelemetryRecorder.RecordEvent((TelemetryEvent)(object)val);
        }
Exemplo n.º 16
0
        protected virtual async Task GenerateFault <T>(ConsumeContext <T> context, Exception exception)
            where T : class
        {
            if (context.ReceiveContext.PublishFaults || context.FaultAddress != null || context.ResponseAddress != null)
            {
                Fault <T> fault = new FaultEvent <T>(context.Message, context.MessageId, HostMetadataCache.Host, exception,
                                                     context.SupportedMessageTypes.ToArray());

                var faultPipe = new FaultPipe <T>(context);

                var faultEndpoint = context.ReceiveContext is InMemoryOutboxReceiveContext
                    ? await this.GetFaultEndpoint <T>().ConfigureAwait(false)
                    : await context.GetFaultEndpoint <T>().ConfigureAwait(false);

                await faultEndpoint.Send(fault, faultPipe, CancellationToken).ConfigureAwait(false);
            }
        }
Exemplo n.º 17
0
 private TReturn HandleFaultEvent <TReturn>(string methodName, Exception exceptionValue, object returnValue)
 {
     if (FaultListeners != null)
     {
         var faultEvent = new FaultEvent()
         {
             MethodName  = methodName,
             Exception   = exceptionValue,
             ReturnValue = returnValue
         };
         FaultListeners(faultEvent);
     }
     if (exceptionValue != null)
     {
         throw exceptionValue;
     }
     return((TReturn)returnValue);
 }
Exemplo n.º 18
0
        public void PostFault(TelemetryIdentifier telemetryIdentifier, string description)
        {
            //IL_002a: Unknown result type (might be due to invalid IL or missing references)
            //IL_0030: Expected O, but got Unknown
            //IL_003f: Unknown result type (might be due to invalid IL or missing references)
            //IL_0044: Unknown result type (might be due to invalid IL or missing references)
            if (telemetryIdentifier == null)
            {
                throw new ArgumentNullException("telemetryIdentifier");
            }
            if (string.IsNullOrEmpty(description))
            {
                throw new ArgumentNullException("description");
            }
            FaultEvent val = (FaultEvent)(object)new FaultEvent(telemetryIdentifier.Value, description, (Exception)null, (Func <IFaultUtility, int>)null);

            EndEvent.Correlate(((TelemetryEvent)val).Correlation);
            TelemetryRecorder.RecordEvent((TelemetryEvent)(object)val);
        }
Exemplo n.º 19
0
        async Task GenerateFault <T>(ConsumeContext <T> context, Exception exception)
            where T : class
        {
            Fault <T> fault = new FaultEvent <T>(context.Message, context.MessageId, HostMetadataCache.Host, exception);

            var faultPipe = new FaultPipe <T>(context);

            var destinationAddress = FaultAddress ?? ResponseAddress;

            if (destinationAddress != null)
            {
                var endpoint = await GetSendEndpoint(destinationAddress).ConfigureAwait(false);

                await ConsumeTask(endpoint.Send(fault, faultPipe, CancellationToken)).ConfigureAwait(false);
            }
            else
            {
                await Publish(fault, faultPipe, CancellationToken).ConfigureAwait(false);
            }
        }
Exemplo n.º 20
0
        /// <summary>
        /// Run an automatic fault scan
        /// </summary>
        public void RunAutoFltScan()
        {
            byte OldValue = GetRegister(0x00);
            //Write 100x010x by keeping existing values for ...x...x and adding 0x84
            byte NewValue = (byte)((OldValue & 0x11) | 0x84); //Everything by D5,D3 and D2...plus the falut clear bit

            Debug.WriteLine("Run Fault Scan: Old:" + OldValue.ToString("X") + " New:" + NewValue.ToString("X"));

            SetRegister(0x00, NewValue);
            while ((GetRegister(0x00) & 0x0C) > 0)
            {
                ;
            }
            byte FaultByte = GetRegister((byte)Register.FLT_STATUS);

            if (FaultByte > 0)
            {
                FaultEvent?.Invoke(this, FaultByte);
            }
        }
Exemplo n.º 21
0
        protected virtual async Task GenerateFault <T>(ConsumeContext <T> context, Exception exception)
            where T : class
        {
            if (context.ReceiveContext.PublishFaults || context.FaultAddress != null || context.ResponseAddress != null)
            {
                Fault <T> fault = new FaultEvent <T>(context.Message, context.MessageId, HostMetadataCache.Host, exception,
                                                     context.SupportedMessageTypes.ToArray());

                var faultPipe = new FaultPipe <T>(context);

                ConsumeContext faultContext = context;
                while (faultContext.TryGetPayload <InMemoryOutboxConsumeContext>(out var outboxConsumeContext))
                {
                    faultContext = outboxConsumeContext.CapturedContext;
                }

                var faultEndpoint = await faultContext.GetFaultEndpoint <T>().ConfigureAwait(false);

                await faultEndpoint.Send(fault, faultPipe, CancellationToken).ConfigureAwait(false);
            }
        }
Exemplo n.º 22
0
        /// <summary>
        /// Report Non-Fatal Watson
        /// </summary>
        /// <param name="description">any description you want to save with this watson report</param>
        /// <param name="exception">Exception that triggered this non-fatal error</param>
        /// <param name="callback">Callback to include extra data with the NFW. Note that we always collect
        /// a dump of the current process, but this can be used to add further information or files to the
        /// CAB.</param>
        public static void Report(string description, Exception exception, Func <IFaultUtility, int> callback)
        {
            var emptyCallstack = exception.SetCallstackIfEmpty();

            // if given exception is non recoverable exception,
            // crash instead of NFW
            if (IsNonRecoverableException(exception))
            {
                CodeAnalysis.FailFast.OnFatalException(exception);
            }

            if (!exception.ShouldReport())
            {
                return;
            }

            if (SessionOpt == null)
            {
                return;
            }

            var faultEvent = new FaultEvent(
                eventName: FunctionId.NonFatalWatson.GetEventName(),
                description: description,
                exceptionObject: exception,
                gatherEventDetails: arg =>
            {
                // always add current processes dump
                arg.AddProcessDump(System.Diagnostics.Process.GetCurrentProcess().Id);

                return(callback(arg));
            });

            // add extra bucket parameters to bucket better in NFW
            // we do it here so that it gets bucketted better in both
            // watson and telemetry.
            faultEvent.SetExtraParameters(exception, emptyCallstack);

            SessionOpt.PostEvent(faultEvent);
        }
Exemplo n.º 23
0
        /// <summary>
        /// Report Non-Fatal Watson
        /// </summary>
        /// <param name="description">any description you want to save with this watson report</param>
        /// <param name="exception">Exception that triggered this non-fatal error</param>
        /// <param name="callback">Callback to include extra data with the NFW. Note that we always collect
        /// a dump of the current process, but this can be used to add further information or files to the
        /// CAB.</param>
        /// <param name="severity">indicate <see cref="WatsonSeverity"/> of NFW</param>
        public static void Report(string description, Exception exception, Func <IFaultUtility, int> callback, WatsonSeverity severity = WatsonSeverity.Default)
        {
            var critical       = severity == WatsonSeverity.Critical;
            var emptyCallstack = exception.SetCallstackIfEmpty();

            if (!WatsonDisabled.s_reportWatson ||
                !exception.ShouldReport())
            {
                return;
            }

            var faultEvent = new FaultEvent(
                eventName: FunctionId.NonFatalWatson.GetEventName(),
                description: description,
                critical ? FaultSeverity.Critical : FaultSeverity.Diagnostic,
                exceptionObject: exception,
                gatherEventDetails: arg =>
            {
                // always add current processes dump
                arg.AddProcessDump(System.Diagnostics.Process.GetCurrentProcess().Id);

                return(callback(arg));
            });

            // add extra bucket parameters to bucket better in NFW
            // we do it here so that it gets bucketted better in both
            // watson and telemetry.
            faultEvent.SetExtraParameters(exception, emptyCallstack);

            TelemetryService.DefaultSession.PostEvent(faultEvent);

            if (exception is OutOfMemoryException || critical)
            {
                // Once we've encountered one OOM or Critial NFW,
                // we're likely to see more. There will probably be other
                // failures as a direct result of the OOM or critical NFW, as well.
                // These aren't helpful so we should just stop reporting failures.
                WatsonDisabled.s_reportWatson = false;
            }
        }
Exemplo n.º 24
0
        public async Task Execute(BehaviorContext <TInstance, TData> context, Behavior <TInstance, TData> next)
        {
            var consumeContext = context.CreateConsumeContext();

            var requestToken = await requestTokenFactory?.Invoke(consumeContext);

            var exception = await exceptionFactory?.Invoke(consumeContext);

            var sendEndpoint = await consumeContext.GetSendEndpoint(requestToken.FaultAddress ?? requestToken.ResponseAddress);

            var fault = new FaultEvent <TRequest>(requestToken.Request, requestToken.MessageId, HostMetadataCache.Host, exception, new string[0]);

            await sendEndpoint.Send(fault, ctx =>
            {
                ctx.CorrelationId  = requestToken.CorrelationId;
                ctx.ConversationId = requestToken.ConversationId;
                ctx.RequestId      = requestToken.RequestId;
                contextCallback?.Invoke(ctx);
            });

            await next.Execute(context).ConfigureAwait(false);
        }
Exemplo n.º 25
0
        // assign the object o, the value v; returns Boolean true if worked, false if failed
        public virtual Object assign(Object o, Object v)
        {
            bool worked = false;

            try
            {
                // we expect that o is a variable that can be resolved or is a specially marked internal variable
                if (o is InternalProperty)
                {
                    worked = assignInternal((InternalProperty)o, v);
                }
                else
                {
                    Variable var = resolveToVariable(o);

                    if (var == null)
                    {
                        throw new NoSuchVariableException(m_current);
                    }

                    // set the value, for the case of a variable that does not exist it will not have a type
                    // so we try to glean one from v.
                    int        type       = determineType(var, v);
                    FaultEvent faultEvent = var.setValue(type, v.ToString());
                    if (faultEvent != null)
                    {
                        throw new PlayerFaultException(faultEvent);
                    }
                    worked = true;
                }
            }
            catch (PlayerDebugException)
            {
                worked = false;
            }

            return(worked);
        }
Exemplo n.º 26
0
        public void RecordFault(string eventName, Exception ex, string description, bool dumpProcess)
        {
            if (this.IsEnabled)
            {
                var fault = new FaultEvent(
                    eventName,
                    !string.IsNullOrEmpty(description) ? description : "Unhandled exception in Cookiecutter extension.",
                    ex
                    );

                if (dumpProcess)
                {
                    fault.AddProcessDump(Process.GetCurrentProcess().Id);
                    fault.IsIncludedInWatsonSample = true;
                }
                else
                {
                    fault.IsIncludedInWatsonSample = false;
                }

                _session.PostEvent(fault);
            }
        }
        public void GetNextDigitalisierungsauftrag_SQL_Server_not_available_returns_service_not_available()
        {
            // Arrange
            var archiveRecord = new ElasticArchiveRecord
            {
                ProtectionEndDate = new ElasticDateWithYear {
                    Date = new DateTime(1900, 12, 31), Year = 1900
                }
            };
            // Setup specific exception that signals that database is down
            var fe = new FaultEvent <OrderDatabaseNotFoundOrNotRunningException>(new OrderDatabaseNotFoundOrNotRunningException(), new Guid(), null,
                                                                                 new OrderDatabaseNotFoundOrNotRunningException(), null);
            var ex = new RequestFaultException("", fe);

            var controller = ArrangeControllerForGetNextDigitalisierungsauftragWithDigipoolException(ex, archiveRecord);

            // Act
            var auftrag = controller.GetNextDigitalisierungsauftrag().GetAwaiter().GetResult();

            // Assert
            auftrag.Should().BeOfType <NegotiatedContentResult <string> >();
            ((NegotiatedContentResult <string>)auftrag).StatusCode.Should().Be(HttpStatusCode.ServiceUnavailable);
        }
Exemplo n.º 28
0
        // pretty print a fault statement to the console
        internal virtual void dumpFaultLine(FaultEvent e)
        {
            System.Text.StringBuilder sb = new System.Text.StringBuilder();
            // use a slightly different format for ConsoleErrorFaults
            if (e is ConsoleErrorFault)
            {
                sb.Append(TextHelper.GetString("Info.LinePrefixWhenDisplayingConsoleError"));                 //$NON-NLS-1$
                sb.Append(' ');
                sb.Append(e.information);
            }
            else
            {
                String name = e.name();
                sb.Append(TextHelper.GetString("Info.LinePrefixWhenDisplayingFault")); //$NON-NLS-1$
                sb.Append(' ');
                sb.Append(name);
                if ((string)e.information != null && e.information.length() > 0)
                {
                    sb.Append(TextHelper.GetString("Info.InformationAboutFault")); //$NON-NLS-1$
                    sb.Append(e.information);
                }
                if (PluginMain.settingObject.VerboseOutput)
                {
                    sb.AppendLine();
                    sb.Append(e.stackTrace());
                }
            }

            if (e.isolateId == 1)
            {
                TraceManager.AddAsync(sb.ToString(), 3);
            }
            else
            {
                TraceManager.AddAsync("Worker " + e.isolateId + ": " + sb.ToString(), 3);
            }
        }
Exemplo n.º 29
0
 /// <summary>
 /// Process events from the queue.
 /// Process all events.
 /// </summary>
 public void ProcessEvents()
 {
     try
     {
         if (base.IsDisposed)
         {
             throw new ObjectDisposedException(GetType().Name, "it is not allowed to process events after channel is disposed");
         }
         if (scheduler.CanEnterTimedDelegate())
         {
             TelemetryEvent result;
             while (queue.TryDequeue(out result))
             {
                 eventProcessor.ProcessEvent(result);
             }
             if (!hasProcessedEvents)
             {
                 hasProcessedEvents = true;
                 initializedAction();
             }
         }
     }
     catch (Exception exceptionObject)
     {
         FaultEvent faultEvent = new FaultEvent("VS/Telemetry/InternalFault", $"Exception in SessionChannel.EventProcessorChannel ProcessEvents Channel = {ChannelId}", exceptionObject)
         {
             PostThisEventToTelemetry = false
         };
         faultEvent.AddProcessDump(Process.GetCurrentProcess().Id);
         telemetrySession.PostEvent(faultEvent);
     }
     finally
     {
         scheduler.ExitTimedDelegate();
     }
 }
        // pretty print a fault statement to the console
        internal virtual void dumpFaultLine(FaultEvent e)
        {
            StringBuilder sb = new StringBuilder();
            // use a slightly different format for ConsoleErrorFaults
            if (e is ConsoleErrorFault)
            {
                sb.Append(TextHelper.GetString("Info.LinePrefixWhenDisplayingConsoleError")); //$NON-NLS-1$
                sb.Append(' ');
                sb.Append(e.information);
            }
            else
            {
                String name = e.name();
                sb.Append(TextHelper.GetString("Info.LinePrefixWhenDisplayingFault")); //$NON-NLS-1$
                sb.Append(' ');
                sb.Append(name);
                if ((string)e.information != null && e.information.length() > 0)
                {
                    sb.Append(TextHelper.GetString("Info.InformationAboutFault")); //$NON-NLS-1$
                    sb.Append(e.information);
                }
                if (PluginMain.settingObject.VerboseOutput)
                {
                    sb.AppendLine();
                    sb.Append(e.stackTrace());
                }
            }

            if (e.isolateId == 1)
                TraceManager.AddAsync(sb.ToString(), 3);
            else
                TraceManager.AddAsync("Worker " + e.isolateId + ": " + sb.ToString(), 3);
        }
Exemplo n.º 31
0
 // pretty print a fault statement to the console
 internal virtual void dumpFaultLine(FaultEvent e)
 {
     System.Text.StringBuilder sb = new System.Text.StringBuilder();
     // use a slightly different format for ConsoleErrorFaults
     if (e is ConsoleErrorFault)
     {
         sb.Append(TextHelper.GetString("Info.LinePrefixWhenDisplayingConsoleError")); //$NON-NLS-1$
         sb.Append(' ');
         sb.Append(e.information);
     }
     else
     {
         String name = e.name();
         sb.Append(TextHelper.GetString("Info.LinePrefixWhenDisplayingFault")); //$NON-NLS-1$
         sb.Append(' ');
         sb.Append(name);
         if ((string)e.information != null && e.information.length() > 0)
         {
             sb.Append(TextHelper.GetString("Info.InformationAboutFault")); //$NON-NLS-1$
             sb.Append(e.information);
         }
     }
     TraceManager.AddAsync(sb.ToString(), 3);
 }
Exemplo n.º 32
0
        public void PostEvent(TelemetryEvent telemetryEvent)
        {
            CodeContract.RequiresArgumentNotNull <TelemetryEvent>(telemetryEvent, "telemetryEvent");
            if (!TelemetrySession.IsOptedIn)
            {
                return;
            }
            FaultEvent faultEvent = telemetryEvent as FaultEvent;

            if (faultEvent == null)
            {
                throw new InvalidOperationException("WatsonSession channel must have FaultEvent posted");
            }
            int num = FaultEventWatsonSamplePercent;

            faultEvent.ReservedProperties["DataModel.Fault.WatsonSamplePercentDefault"] = FaultEventWatsonSamplePercent;
            if (FaultEvent.WatsonSamplePercent.HasValue)
            {
                num = FaultEvent.WatsonSamplePercent.Value;
                faultEvent.ReservedProperties["DataModel.Fault.WatsonSamplePercentOverride"] = FaultEvent.WatsonSamplePercent.Value;
            }
            if (!faultEvent.IsIncludedInWatsonSample.HasValue)
            {
                faultEvent.UserOptInToWatson = FaultEvent.FaultEventWatsonOptIn.Unspecified;
                if (num > 0)
                {
                    faultEvent.IsIncludedInWatsonSample = (Random.Next(100) < num);
                }
                else
                {
                    faultEvent.IsIncludedInWatsonSample = false;
                }
            }
            else
            {
                if (faultEvent.IsIncludedInWatsonSample == true)
                {
                    faultEvent.UserOptInToWatson = FaultEvent.FaultEventWatsonOptIn.PropertyOptIn;
                }
                else
                {
                    faultEvent.UserOptInToWatson = FaultEvent.FaultEventWatsonOptIn.PropertyOptOut;
                }
                faultEvent.Properties["VS.Fault.WatsonOptIn"] = faultEvent.UserOptInToWatson.ToString();
            }
            WatsonReport watsonReport = new WatsonReport(faultEvent, TelemetrySession);
            int          num2         = FaultEventMaximumWatsonReportsPerSession;

            faultEvent.ReservedProperties["DataModel.Fault.MaxReportsPerSessionDefault"] = FaultEventMaximumWatsonReportsPerSession;
            if (FaultEvent.MaximumWatsonReportsPerSession.HasValue)
            {
                num2 = FaultEvent.MaximumWatsonReportsPerSession.Value;
                faultEvent.ReservedProperties["DataModel.Fault.MaxReportsPerSessionOverride"] = FaultEventMaximumWatsonReportsPerSession;
            }
            if (num == 0 && num2 == 0)
            {
                faultEvent.IsIncludedInWatsonSample = false;
            }
            int minSecondsBetweenReports = FaultEventMinimumSecondsBetweenWatsonReports;

            faultEvent.ReservedProperties["DataModel.Fault.MinSecondsBetweenReportsDefault"] = FaultEventMinimumSecondsBetweenWatsonReports;
            if (FaultEvent.MinimumSecondsBetweenWatsonReports.HasValue)
            {
                minSecondsBetweenReports = FaultEvent.MinimumSecondsBetweenWatsonReports.Value;
                faultEvent.ReservedProperties["DataModel.Fault.MinSecondsBetweenReportsOverride"] = FaultEvent.MinimumSecondsBetweenWatsonReports;
            }
            watsonReport.PostWatsonReport(num2, minSecondsBetweenReports);
        }