Skip to content

Commit

Permalink
Make FirstChanceExceptionHandler CCTOR Safe
Browse files Browse the repository at this point in the history
  • Loading branch information
Solxanich committed Aug 11, 2023
1 parent f96985f commit 1cf5af1
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,6 @@ private static void Archive()
if (existingLogArchives.Length > 0)
n = existingLogArchives.Select(s => int.Parse(pattern.Match(Path.GetFileName(s)).Groups[1].Value)).Max() + 1;


// Initiate the ZIP.
try {
using (var zip = new ZipFile(Path.Combine(Logging.LogArchiveDir, $"{time:yyyy-MM-dd}-{n}.zip"), Encoding.UTF8)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,8 @@ private static void FirstChanceExceptionHandler(object sender, FirstChanceExcept
previousException = args.Exception;

string msg = args.Exception.Message + " " + Language.GetTextValue("tModLoader.RuntimeErrorSeeLogsForFullTrace", Path.GetFileName(LogPath));
if (Main.dedServ) { // TODO, sometimes console write fails on unix clients. Hopefully it doesn't happen on servers? System.IO.IOException: Input/output error at System.ConsolePal.Write
// Solxan: We are using Program.SavePathShared == null as a flag to indicate Main CCtor can't run.
if (Program.SavePathShared == null || Main.dedServ) { // TODO, sometimes console write fails on unix clients. Hopefully it doesn't happen on servers? System.IO.IOException: Input/output error at System.ConsolePal.Write
Console.ForegroundColor = ConsoleColor.DarkMagenta;
Console.WriteLine(msg);
Console.ResetColor();
Expand Down

0 comments on commit 1cf5af1

Please sign in to comment.