CEngineSharp_Server.Utilities.ErrorHandler.HandleException C# (CSharp) Method

HandleException() public static method

Handles a server exception by logging it and, if neccessary, shutting down the server.
public static HandleException ( Exception exception, ErrorLevels errorLevel ) : void
exception System.Exception The exception object that describes the error that has occured.
errorLevel ErrorLevels The projected severity of the error that has occured.
return void
        public static void HandleException(Exception exception, ErrorLevels errorLevel)
        {
            try
            {
                if (ServerConfiguration.SupressionLevel == ErrorLevels.Debug)
                    throw new Exception("Debug Mode", exception);

                // Invoke the method that will log our error in a log-file.
                LogError(exception, errorLevel);

                // If the error that has occured has an error level higher than what we're supressing,
                // Notify the end user that the error is unrecoverable and shut everything down.
                if ((int)errorLevel >= (int)ServerConfiguration.SupressionLevel)
                {
                    Console.WriteLine("An unrecoverable error has occured; please check the error log files for additional details.");

                    // Keep the program alive for 5 seconds.
                    Thread.Sleep(5000);

                    // Set the ShuttingDown variable to true.
                    // This will notify the GameLoop that it is time to clean things up.
                    Server.ShuttingDown = true;
                }
            }
            catch (Exception)
            {
                Console.WriteLine(exception.Message + ": " + exception.StackTrace);
                Console.ReadLine();
                Server.ShuttingDown = true;
            }
        }