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

LogException() static private method

static private LogException ( Exception e, string msg = "The game has crashed!" ) : void
e System.Exception
msg string
return void
		internal static void LogException(Exception e, string msg = "The game has crashed!")
		{
			Directory.CreateDirectory(LogPath);
			string file = LogPath + Path.DirectorySeparatorChar + "Runtime Error.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;
				}
			}
			Interface.errorMessage.SetMessage(msg + "\n\n" + e.Message + "\n" + e.StackTrace);
			Interface.errorMessage.SetGotoMenu(0);
			Interface.errorMessage.SetFile(file);
			Main.gameMenu = true;
			Main.menuMode = Interface.errorMessageID;
		}

Usage Example

Exemplo n.º 1
0
        internal static LocalMod[] FindMods()
        {
            Directory.CreateDirectory(ModPath);
            var mods = new List <LocalMod>();

            foreach (string fileName in Directory.GetFiles(ModPath, "*.tmod", SearchOption.TopDirectoryOnly))
            {
                var lastModified = File.GetLastWriteTime(fileName);
                if (!modsDirCache.TryGetValue(fileName, out var mod) || mod.lastModified != lastModified)
                {
                    var modFile = new TmodFile(fileName);
                    try
                    {
                        modFile.Read(TmodFile.LoadedState.Info);
                    }
                    catch (Exception e)                     //this will probably spam, given the number of calls to FindMods
                    {
                        ErrorLogger.LogException(e, Language.GetTextValue("tModLoader.LoadErrorErrorReadingModFile", modFile.path));
                        continue;
                    }

                    mod = new LocalMod(modFile)
                    {
                        lastModified = lastModified
                    };
                    modsDirCache[fileName] = mod;
                }
                mods.Add(mod);
            }
            return(mods.OrderBy(x => x.Name, StringComparer.InvariantCulture).ToArray());
        }
All Usage Examples Of Terraria.ModLoader.ErrorLogger::LogException