Ejemplo n.º 1
0
        public static Exception AssertAndFailFastService(string description)
        {
            Fx.Assert(description);
            string failFastMessage = CommonResources.GetString(CommonResources.FailFastMessage, description);

            // The catch is here to force the finally to run, as finallys don't run until the stack walk gets to a catch.
            // The catch makes sure that the finally will run before the stack-walk leaves the frame, but the code inside is impossible to reach.
            try
            {
                try
                {
                    ////MessagingClientEtwProvider.Provider.EventWriteFailFastOccurred(description);
                    Fx.Exception.TraceFailFast(failFastMessage);

                    // Mark that a FailFast is in progress, so that we can take ourselves out of the NLB if for
                    // any reason we can't kill ourselves quickly.  Wait 15 seconds so this state gets picked up for sure.
                    Fx.FailFastInProgress = true;
#if !WINDOWS_UWP
                    Thread.Sleep(TimeSpan.FromSeconds(15));
#endif
                }
                finally
                {
#if !WINDOWS_UWP
                    // ########################## NOTE ###########################
                    // Environment.FailFast does not collect crash dumps when used in Azure services.
                    // Environment.FailFast(failFastMessage);

                    // ################## WORKAROUND #############################
                    // Workaround for the issue above. Throwing an unhandled exception on a separate thread to trigger process crash and crash dump collection
                    // Throwing FatalException since our service does not morph/eat up fatal exceptions
                    // We should find the tracking bug in Azure for this issue, and remove the workaround when fixed by Azure
                    Thread failFastWorkaroundThread = new Thread(delegate()
                    {
                        throw new FatalException(failFastMessage);
                    });

                    failFastWorkaroundThread.Start();
                    failFastWorkaroundThread.Join();
#endif
                }
            }
            catch
            {
                throw;
            }

            return(null); // we'll never get here since we've just fail-fasted
        }
Ejemplo n.º 2
0
        public static Exception AssertAndFailFastService(string description)
        {
            Assert(description);
            string failFastMessage = CommonResources.GetString(Resources.FailFastMessage, description);

            // The catch is here to force the finally to run, as finallys don't run until the stack walk gets to a catch.
            // The catch makes sure that the finally will run before the stack-walk leaves the frame, but the code inside is impossible to reach.
            try
            {
                try
                {
                    Thread.Sleep(TimeSpan.FromSeconds(15));
                }
                finally
                {
                    // ########################## NOTE ###########################
                    // Environment.FailFast does not collect crash dumps when used in Azure services.
                    // Environment.FailFast(failFastMessage);

                    // ################## WORKAROUND #############################
                    // Workaround for the issue above. Throwing an unhandled exception on a separate thread to trigger process crash and crash dump collection
                    // Throwing FatalException since our service does not morph/eat up fatal exceptions
                    // We should find the tracking bug in Azure for this issue, and remove the workaround when fixed by Azure
                    var failFastWorkaroundThread = new Thread(
                        delegate()
                    {
#pragma warning disable CA2219 // Do not raise exceptions in finally clauses
                        throw new FatalException(failFastMessage);
#pragma warning restore CA2219 // Do not raise exceptions in finally clauses
                    });

                    failFastWorkaroundThread.Start();
                    failFastWorkaroundThread.Join();
                }
            }
            catch
            {
                throw;
            }

            return(null); // we'll never get here since we've just fail-fasted
        }
Ejemplo n.º 3
0
 public ArgumentException ArgumentNullOrWhiteSpace(string paramName)
 {
     return(this.Argument(paramName, CommonResources.GetString(CommonResources.ArgumentNullOrWhiteSpace, paramName)));
 }
Ejemplo n.º 4
0
 public ArgumentException ArgumentNullOrEmpty(string paramName)
 {
     return(Argument(paramName, CommonResources.GetString(CommonResources.ArgumentNullOrEmpty, paramName)));
 }
Ejemplo n.º 5
0
 public AssertionFailedException(string description)
     : base(CommonResources.GetString(CommonResources.ShipAssertExceptionMessage, description))
 {
 }
Ejemplo n.º 6
0
 protected static void ThrowInvalidAsyncResult(IAsyncResult result)
 {
     throw Fx.Exception.AsError(new InvalidOperationException(CommonResources.GetString(CommonResources.InvalidAsyncResultImplementation, result.GetType())));
 }