LogException() static private method

static private LogException ( Exception e, string msg = "The game has crashed!" ) : void
e System.Exception
msg string
return void
Ejemplo 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());
        }
Ejemplo n.º 2
0
 internal static void BuildMod()
 {
     Interface.buildMod.SetProgress(0, 1);
     ThreadPool.QueueUserWorkItem(_ =>
     {
         try
         {
             PostBuildMenu(ModCompile.Build(modToBuild, Interface.buildMod));
         }
         catch (Exception e)
         {
             ErrorLogger.LogException(e);
         }
     }, 1);
 }
Ejemplo n.º 3
0
 internal static void BuildMod()
 {
     Interface.buildMod.SetProgress(0, 1);
     ThreadPool.QueueUserWorkItem(new WaitCallback(delegate(object threadContext)
     {
         try
         {
             do_BuildMod(threadContext);
         }
         catch (Exception e)
         {
             ErrorLogger.LogException(e);
         }
     }), 1);
 }
Ejemplo n.º 4
0
        internal static void ReceiveMod(BinaryReader reader)
        {
            if (downloadingMod == null)
            {
                return;
            }

            try
            {
                if (downloadingFile == null)
                {
                    Interface.downloadMod.SetDownloading(reader.ReadString());
                    Interface.downloadMod.SetCancel(() =>
                    {
                        downloadingFile?.Close();
                        downloadingMod     = null;
                        Netplay.disconnect = true;
                        Main.menuMode      = 0;
                    });
                    Main.menuMode = Interface.downloadModID;

                    downloadingLength = reader.ReadInt64();
                    downloadingFile   = new FileStream(downloadingMod.path, FileMode.Create);
                    return;
                }

                var bytes = reader.ReadBytes((int)Math.Min(downloadingLength - downloadingFile.Position, CHUNK_SIZE));
                downloadingFile.Write(bytes, 0, bytes.Length);
                Interface.downloadMod.SetProgress(downloadingFile.Position, downloadingLength);

                if (downloadingFile.Position == downloadingLength)
                {
                    downloadingFile.Close();
                    var mod = new TmodFile(downloadingMod.path);
                    mod.Read(TmodFile.LoadedState.Info);

                    if (!downloadingMod.Matches(mod))
                    {
                        throw new Exception(Language.GetTextValue("tModLoader.MPErrorModHashMismatch"));
                    }

                    if (downloadingMod.signed && !mod.ValidModBrowserSignature)
                    {
                        throw new Exception(Language.GetTextValue("tModLoader.MPErrorModNotSigned"));
                    }

                    ModLoader.EnableMod(mod.name);

                    if (downloadQueue.Count > 0)
                    {
                        DownloadNextMod();
                    }
                    else
                    {
                        OnModsDownloaded(true);
                    }
                }
            }
            catch (Exception e)
            {
                try
                {
                    downloadingFile?.Close();
                }
                catch { }

                File.Delete(downloadingMod.path);
                ErrorLogger.LogException(e, Language.GetTextValue("tModLoader.MPErrorModDownloadError", downloadingMod.name));
                downloadingMod = null;
            }
        }