diff options
author | Jesse Plamondon-Willard <github@jplamondonw.com> | 2017-03-01 19:18:21 -0500 |
---|---|---|
committer | Jesse Plamondon-Willard <github@jplamondonw.com> | 2017-03-01 19:18:21 -0500 |
commit | 696bdab3cd3352b439207076d604f21bbcf1d922 (patch) | |
tree | 3ecfd2537dddd71e4eedcb1026e650c1908b4d1d | |
parent | 6de4888a1b3e62f3b3976ba013521fbd79405288 (diff) | |
download | SMAPI-696bdab3cd3352b439207076d604f21bbcf1d922.tar.gz SMAPI-696bdab3cd3352b439207076d604f21bbcf1d922.tar.bz2 SMAPI-696bdab3cd3352b439207076d604f21bbcf1d922.zip |
fix errors in console command handlers crashing the game
-rw-r--r-- | release-notes.md | 1 | ||||
-rw-r--r-- | src/StardewModdingAPI/Program.cs | 11 |
2 files changed, 10 insertions, 2 deletions
diff --git a/release-notes.md b/release-notes.md index 81d770f0..797da19d 100644 --- a/release-notes.md +++ b/release-notes.md @@ -15,6 +15,7 @@ For players: * Fixed installer not ignoring potential game folders that don't contain a Stardew Valley exe. * Fixed installer not recognising Linux/Mac paths starting with `~/` or containing an escaped space. * Fixed rare issue where mod dependencies would override SMAPI dependencies and cause unpredictable bugs. +* Fixed errors in console command handlers causing the game to crash. For mod developers: * Added `SaveEvents.AfterReturnToTitle` and `TimeEvents.AfterDayStarted` events. diff --git a/src/StardewModdingAPI/Program.cs b/src/StardewModdingAPI/Program.cs index 07857512..ebeefe96 100644 --- a/src/StardewModdingAPI/Program.cs +++ b/src/StardewModdingAPI/Program.cs @@ -535,8 +535,15 @@ namespace StardewModdingAPI while (true) { string input = Console.ReadLine(); - if (!string.IsNullOrWhiteSpace(input) && !this.CommandManager.Trigger(input)) - this.Monitor.Log("Unknown command; type 'help' for a list of available commands.", LogLevel.Error); + try + { + if (!string.IsNullOrWhiteSpace(input) && !this.CommandManager.Trigger(input)) + this.Monitor.Log("Unknown command; type 'help' for a list of available commands.", LogLevel.Error); + } + catch (Exception ex) + { + this.Monitor.Log($"The handler registered for that command failed:\n{ex.GetLogSummary()}", LogLevel.Error); + } } } |