diff options
author | Jesse Plamondon-Willard <github@jplamondonw.com> | 2017-05-09 01:46:40 -0400 |
---|---|---|
committer | Jesse Plamondon-Willard <github@jplamondonw.com> | 2017-05-09 01:46:40 -0400 |
commit | 3d732275874e2f36e13f10813e08b7ed2fc143f8 (patch) | |
tree | 99c8039a53f0344ef0e32a0e19d2ede1cfe925fe /src/StardewModdingAPI/Program.cs | |
parent | 467d4a27ee565433559c9dc374f5c95107938498 (diff) | |
download | SMAPI-3d732275874e2f36e13f10813e08b7ed2fc143f8.tar.gz SMAPI-3d732275874e2f36e13f10813e08b7ed2fc143f8.tar.bz2 SMAPI-3d732275874e2f36e13f10813e08b7ed2fc143f8.zip |
when a fatal crash happens, keep a copy of the log and notify the player on relaunch
Diffstat (limited to 'src/StardewModdingAPI/Program.cs')
-rw-r--r-- | src/StardewModdingAPI/Program.cs | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/src/StardewModdingAPI/Program.cs b/src/StardewModdingAPI/Program.cs index aa78ff41..725ac94f 100644 --- a/src/StardewModdingAPI/Program.cs +++ b/src/StardewModdingAPI/Program.cs @@ -154,7 +154,16 @@ namespace StardewModdingAPI this.CancellationTokenSource.Token.WaitHandle.WaitOne(); if (this.IsGameRunning) { - this.GameInstance.Exiting += (sender, e) => this.PressAnyKeyToExit(); + try + { + File.WriteAllText(Constants.FatalCrashMarker, string.Empty); + File.Copy(Constants.DefaultLogPath, Constants.FatalCrashLog, overwrite: true); + } + catch (Exception ex) + { + this.Monitor.Log($"SMAPI failed trying to track the crash details: {ex.GetLogSummary()}"); + } + this.GameInstance.Exit(); } }).Start(); @@ -179,6 +188,17 @@ namespace StardewModdingAPI return; } + // show details if game crashed during last session + if (File.Exists(Constants.FatalCrashMarker)) + { + this.Monitor.Log("The game crashed last time you played. That can be due to bugs in the game, but if it happens repeatedly you can ask for help here: http://community.playstarbound.com/threads/108375/.", LogLevel.Error); + this.Monitor.Log($"If you ask for help, make sure to attach this file: {Constants.FatalCrashLog}", LogLevel.Error); + this.Monitor.Log("Press any key to delete the crash data and continue playing.", LogLevel.Info); + Console.ReadKey(); + File.Delete(Constants.FatalCrashLog); + File.Delete(Constants.FatalCrashMarker); + } + // start game this.Monitor.Log("Starting game..."); try |