diff options
author | Jesse Plamondon-Willard <github@jplamondonw.com> | 2017-04-27 15:46:19 -0400 |
---|---|---|
committer | Jesse Plamondon-Willard <github@jplamondonw.com> | 2017-04-27 15:46:19 -0400 |
commit | 40f174b22d4ceb93281a03414048c04598780170 (patch) | |
tree | 5c8314e29e9ca783fc94587d3e32350c34fce48c /src/StardewModdingAPI | |
parent | 0cf15d36d9e6f5a40a16e17f3bd3d53682fe648c (diff) | |
download | SMAPI-40f174b22d4ceb93281a03414048c04598780170.tar.gz SMAPI-40f174b22d4ceb93281a03414048c04598780170.tar.bz2 SMAPI-40f174b22d4ceb93281a03414048c04598780170.zip |
simplify exception summary code
Diffstat (limited to 'src/StardewModdingAPI')
-rw-r--r-- | src/StardewModdingAPI/Framework/InternalExtensions.cs | 25 |
1 files changed, 12 insertions, 13 deletions
diff --git a/src/StardewModdingAPI/Framework/InternalExtensions.cs b/src/StardewModdingAPI/Framework/InternalExtensions.cs index 2f6f7490..5199c72d 100644 --- a/src/StardewModdingAPI/Framework/InternalExtensions.cs +++ b/src/StardewModdingAPI/Framework/InternalExtensions.cs @@ -92,21 +92,20 @@ namespace StardewModdingAPI.Framework /// <param name="exception">The error to summarise.</param> public static string GetLogSummary(this Exception exception) { - // type load exception - if (exception is TypeLoadException typeLoadEx) - return $"Failed loading type: {typeLoadEx.TypeName}: {exception}"; - - // reflection type load exception - if (exception is ReflectionTypeLoadException reflectionTypeLoadEx) + switch (exception) { - string summary = exception.ToString(); - foreach (Exception childEx in reflectionTypeLoadEx.LoaderExceptions) - summary += $"\n\n{childEx.GetLogSummary()}"; - return summary; - } + case TypeLoadException ex: + return $"Failed loading type '{ex.TypeName}': {exception}"; - // anything else - return exception.ToString(); + case ReflectionTypeLoadException ex: + string summary = exception.ToString(); + foreach (Exception childEx in ex.LoaderExceptions) + summary += $"\n\n{childEx.GetLogSummary()}"; + return summary; + + default: + return exception.ToString(); + } } /**** |