Skip to content

Commit

Permalink
Only log silently caught exceptions to console in servers. (tModLoade…
Browse files Browse the repository at this point in the history
  • Loading branch information
Chicken-Bones authored Jun 29, 2022
1 parent c088eb0 commit 2bcc2f3
Showing 1 changed file with 8 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -104,23 +104,23 @@ private static void FirstChanceExceptionHandler(object sender, FirstChanceExcept
return;
}

tML.Warn(Language.GetTextValue("tModLoader.RuntimeErrorSilentlyCaughtException") + '\n' + exString);

previousException = args.Exception;
string msg = args.Exception.Message + " " + Language.GetTextValue("tModLoader.RuntimeErrorSeeLogsForFullTrace", Path.GetFileName(LogPath));

if (!Main.dedServ && ModCompile.activelyModding && !Main.gameMenu) {
AddChatMessage(msg);
}
else {
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
Console.ForegroundColor = ConsoleColor.DarkMagenta;
Console.WriteLine(msg);
Console.ResetColor();
}

tML.Warn(Language.GetTextValue("tModLoader.RuntimeErrorSilentlyCaughtException") + '\n' + exString);
else if (ModCompile.activelyModding && !Main.gameMenu) {
AddChatMessage(msg);
}

if (oom) {
string error = Language.GetTextValue("tModLoader.OutOfMemory");
Logging.tML.Fatal(error);
tML.Fatal(error);
Interface.MessageBoxShow(error);
Environment.Exit(1);
}
Expand Down

0 comments on commit 2bcc2f3

Please sign in to comment.