summaryrefslogtreecommitdiff
path: root/src/SMAPI.Internal/ExceptionExtensions.cs
diff options
context:
space:
mode:
authorJesse Plamondon-Willard <Pathoschild@users.noreply.github.com>2021-08-25 21:54:00 -0400
committerJesse Plamondon-Willard <Pathoschild@users.noreply.github.com>2021-08-25 21:54:00 -0400
commit211f89821e34bb55a6266384d9bac68ec0c64744 (patch)
treeaa0d9915b01aad436ed6b1a2028602c048666457 /src/SMAPI.Internal/ExceptionExtensions.cs
parent80d3dd1f786f7e5846f9adb7f7a4d82e5b9b92fd (diff)
parent31ac964a8b19623b0472931403a33d51db6fb271 (diff)
downloadSMAPI-211f89821e34bb55a6266384d9bac68ec0c64744.tar.gz
SMAPI-211f89821e34bb55a6266384d9bac68ec0c64744.tar.bz2
SMAPI-211f89821e34bb55a6266384d9bac68ec0c64744.zip
Merge branch 'develop' into stable
Diffstat (limited to 'src/SMAPI.Internal/ExceptionExtensions.cs')
-rw-r--r--src/SMAPI.Internal/ExceptionExtensions.cs27
1 files changed, 17 insertions, 10 deletions
diff --git a/src/SMAPI.Internal/ExceptionExtensions.cs b/src/SMAPI.Internal/ExceptionExtensions.cs
index 5f1ee1fa..d8189048 100644
--- a/src/SMAPI.Internal/ExceptionExtensions.cs
+++ b/src/SMAPI.Internal/ExceptionExtensions.cs
@@ -13,19 +13,26 @@ namespace StardewModdingAPI.Internal
/// <param name="exception">The error to summarize.</param>
public static string GetLogSummary(this Exception exception)
{
- switch (exception)
+ try
{
- case TypeLoadException ex:
- return $"Failed loading type '{ex.TypeName}': {exception}";
+ switch (exception)
+ {
+ case TypeLoadException ex:
+ return $"Failed loading type '{ex.TypeName}': {exception}";
- case ReflectionTypeLoadException ex:
- string summary = ex.ToString();
- foreach (Exception childEx in ex.LoaderExceptions ?? new Exception[0])
- summary += $"\n\n{childEx?.GetLogSummary()}";
- return summary;
+ case ReflectionTypeLoadException ex:
+ string summary = ex.ToString();
+ foreach (Exception childEx in ex.LoaderExceptions ?? new Exception[0])
+ summary += $"\n\n{childEx?.GetLogSummary()}";
+ return summary;
- default:
- return exception.ToString();
+ default:
+ return exception?.ToString() ?? $"<null exception>\n{Environment.StackTrace}";
+ }
+ }
+ catch (Exception ex)
+ {
+ throw new InvalidOperationException($"Failed handling {exception?.GetType().FullName} (original message: {exception?.Message})", ex);
}
}