internal static void LogLoadingError(string modFile, Version modBuildVersion, Exception e, bool recipes = false)
{
Directory.CreateDirectory(LogPath);
string file = LogPath + Path.DirectorySeparatorChar + "Loading Errors.txt";
using (StreamWriter writer = File.CreateText(file))
{
writer.WriteLine(e.Message);
writer.WriteLine(e.StackTrace);
Exception inner = e.InnerException;
while (inner != null)
{
writer.WriteLine();
writer.WriteLine("Inner Exception:");
writer.WriteLine(inner.Message);
writer.WriteLine(inner.StackTrace);
inner = inner.InnerException;
}
}
string message;
if (recipes)
{
message = "An error occurred while adding recipes for " + modFile;
}
else
{
message = "An error occurred while loading " + modFile;
}
if (modBuildVersion != ModLoader.version)
{
message += "\nIt has been detected that this mod was built for tModLoader v" + modBuildVersion;
message += "\nHowever, you are using " + ModLoader.versionedName;
}
message += "\nThis mod has automatically been disabled.";
message += "\n\n" + e.Message + "\n" + e.StackTrace;
if (Main.dedServ)
{
Console.WriteLine(message);
}
Interface.errorMessage.SetMessage(message);
Interface.errorMessage.SetGotoMenu(Interface.reloadModsID);
Interface.errorMessage.SetFile(file);
}
//add try catch to Terraria.WorldGen.worldGenCallBack