Example #1
0
        /// <summary>
        /// This function can be used by the node provider to report a failure which doesn't prevent further
        /// communication with the parent node. The node will attempt to notify the parent of the failure,
        /// send all outstanding logging events and shutdown.
        /// </summary>
        /// <param name="originalException"></param>
        /// <exception cref="Exception">Throws exception (with nested original exception) if reporting to parent fails.</exception>
        internal void ReportUnhandledError(Exception originalException)
        {
            NodeStatus nodeStatus = new NodeStatus(originalException);

            if (Engine.debugMode)
            {
                Console.WriteLine("Node.ReportUnhandledError: " + originalException.Message);
            }

            try
            {
                try
                {
                    PostStatusThrow(nodeStatus, true /* wait for the message to be sent before returning */);
                }
                catch (Exception ex)
                {
                    // If an error occurred while trying to send the original exception to the parent
                    // rethrow the original exception
                    string message = ResourceUtilities.FormatResourceString("FatalErrorOnChildNode", nodeId, ex.Message);

                    ErrorUtilities.LaunchMsBuildDebuggerOnFatalError();

                    throw new Exception(message, originalException);
                }
            }
            finally
            {
                // Makesure we write the exception to a file so even if something goes wrong with the logging or transfer to the parent
                // then we will atleast get the message on disk.
                LocalNode.DumpExceptionToFile(originalException);
            }

            localEngine?.Shutdown();
        }
Example #2
0
        /// <summary>
        /// This method can be used by the node provider to report a fatal communication error, after
        /// which further communication with the parent node is no longer possible. The node provider
        /// can optionally provide a stream to which the current node state will be logged in order
        /// to assist with debugging of the problem.
        /// </summary>
        /// <param name="originalException"></param>
        /// <param name="loggingStream"></param>
        /// <exception cref="Exception">Re-throws exception passed in</exception>
        internal void ReportFatalCommunicationError(Exception originalException, TextWriter loggingStream)
        {
            loggingStream?.WriteLine(originalException.ToString());

            string message = ResourceUtilities.FormatResourceString("FatalErrorOnChildNode", nodeId, originalException.Message);

            ErrorUtilities.LaunchMsBuildDebuggerOnFatalError();

            throw new Exception(message, originalException);
        }
Example #3
0
 /// <summary>
 /// This method is called to shutdown the system in case of fatal error
 /// </summary>
 internal void SystemShutdown()
 {
     ErrorUtilities.LaunchMsBuildDebuggerOnFatalError();
     nodeManager.ShutdownNodes(Node.NodeShutdownLevel.ErrorShutdown);
 }