Added exception handler to initialize. For some reason CurrentDomain_UnhandledException isn't catching it.

This commit is contained in:
high 2011-08-04 18:11:14 -04:00
parent b283fe370d
commit 0801281c91

View file

@ -107,6 +107,9 @@ namespace TShockAPI
AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
try
{
if (File.Exists(Path.Combine(SavePath, "tshock.pid")))
{
Log.ConsoleInfo("TShock was improperly shut down. Deleting invalid pid file...");
@ -138,7 +141,6 @@ namespace TShockAPI
Config.MySqlUsername,
Config.MySqlPassword
);
DB.Open();
}
catch (MySqlException ex)
{
@ -186,6 +188,14 @@ namespace TShockAPI
Log.ConsoleInfo("AutoSave " + (Config.AutoSave ? "Enabled" : "Disabled"));
Log.ConsoleInfo("Backups " + (Backups.Interval > 0 ? "Enabled" : "Disabled"));
}
catch (Exception ex)
{
Log.Error("Fatal Startup Exception");
Log.Error(ex.ToString());
Environment.Exit(1);
}
}
public override void DeInitialize()
@ -240,7 +250,6 @@ namespace TShockAPI
Main.worldPathName += ".crash";
WorldGen.saveWorld();
}
DeInitialize();
}
}