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;
}
}