diff options
author | Jesse Plamondon-Willard <Pathoschild@users.noreply.github.com> | 2021-08-04 18:05:05 -0400 |
---|---|---|
committer | Jesse Plamondon-Willard <Pathoschild@users.noreply.github.com> | 2021-08-04 18:05:05 -0400 |
commit | b6f3ecc143b3a76240775fe75c9b7b643433bbe5 (patch) | |
tree | 39532e789761904f675660dd813672611cb1298e | |
parent | 807dcfec7723156a36524d5f1889b5f3208d97cf (diff) | |
download | SMAPI-b6f3ecc143b3a76240775fe75c9b7b643433bbe5.tar.gz SMAPI-b6f3ecc143b3a76240775fe75c9b7b643433bbe5.tar.bz2 SMAPI-b6f3ecc143b3a76240775fe75c9b7b643433bbe5.zip |
fix error when error-handling invalid ReflectionTypeLoadException errors
-rw-r--r-- | docs/release-notes.md | 1 | ||||
-rw-r--r-- | src/SMAPI.Internal/ExceptionExtensions.cs | 6 |
2 files changed, 4 insertions, 3 deletions
diff --git a/docs/release-notes.md b/docs/release-notes.md index 25a0b4fa..9075a471 100644 --- a/docs/release-notes.md +++ b/docs/release-notes.md @@ -8,6 +8,7 @@ * For mod authors: * Reversed the `Constants.Save*` fix in SMAPI 3.12.1. _The change caused a number of other issues, and was only needed for edge cases where the save folder was invalid._ + * Fixed `NullReferenceException` in SMAPI's error-handling when trying to handle an invalid `ReflectionTypeLoadException`. ## 3.12.1 Released 03 August 2021 for Stardew Valley 1.5.4 or later. diff --git a/src/SMAPI.Internal/ExceptionExtensions.cs b/src/SMAPI.Internal/ExceptionExtensions.cs index d7a2252b..5f1ee1fa 100644 --- a/src/SMAPI.Internal/ExceptionExtensions.cs +++ b/src/SMAPI.Internal/ExceptionExtensions.cs @@ -19,9 +19,9 @@ namespace StardewModdingAPI.Internal return $"Failed loading type '{ex.TypeName}': {exception}"; case ReflectionTypeLoadException ex: - string summary = exception.ToString(); - foreach (Exception childEx in ex.LoaderExceptions) - summary += $"\n\n{childEx.GetLogSummary()}"; + string summary = ex.ToString(); + foreach (Exception childEx in ex.LoaderExceptions ?? new Exception[0]) + summary += $"\n\n{childEx?.GetLogSummary()}"; return summary; default: |