Terraria.ModLoader.ErrorLogger.LogLoadingError C# (CSharp) Method

LogLoadingError() static private method

static private LogLoadingError ( string modFile, System.Version modBuildVersion, Exception e, bool recipes = false ) : void
modFile string
modBuildVersion System.Version
e System.Exception
recipes bool
return void
		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

Usage Example

Exemplo n.º 1
0
        private static bool VerifyNames(List <LoadingMod> mods)
        {
            var names = new HashSet <string>();

            foreach (var mod in mods)
            {
                try
                {
                    if (mod.Name.Length == 0)
                    {
                        throw new ModNameException("Mods must actually have stuff in their names");
                    }

                    if (mod.Name.Equals("Terraria", StringComparison.InvariantCultureIgnoreCase))
                    {
                        throw new ModNameException("Mods names cannot be named Terraria");
                    }

                    if (names.Contains(mod.Name))
                    {
                        throw new ModNameException("Two mods share the internal name " + mod.Name);
                    }

                    names.Add(mod.Name);
                }
                catch (Exception e)
                {
                    DisableMod(mod.modFile);
                    ErrorLogger.LogLoadingError(mod.Name, mod.modFile.tModLoaderVersion, e);
                    return(false);
                }
            }

            return(true);
        }
All Usage Examples Of Terraria.ModLoader.ErrorLogger::LogLoadingError