From 94e97a12d1885c930d4d5e8ccd2f5d10b81d2f6b Mon Sep 17 00:00:00 2001 From: UnknownShadow200 Date: Tue, 14 Jul 2020 13:48:56 +1000 Subject: [PATCH] Also log LoaderExceptions for ReflectionTypeLoadException exceptions --- MCGalaxy/CorePlugin/CorePlugin.cs | 2 +- MCGalaxy/CorePlugin/NotesPlugin.cs | 2 +- MCGalaxy/Server/Logger.cs | 13 +++++++++++++ 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/MCGalaxy/CorePlugin/CorePlugin.cs b/MCGalaxy/CorePlugin/CorePlugin.cs index 327f526b6..7b523dedd 100644 --- a/MCGalaxy/CorePlugin/CorePlugin.cs +++ b/MCGalaxy/CorePlugin/CorePlugin.cs @@ -25,7 +25,7 @@ using MCGalaxy.Tasks; namespace MCGalaxy.Core { - public sealed class CorePlugin : Plugin_Simple { + public sealed class CorePlugin : Plugin { public override string creator { get { return Server.SoftwareName + " team"; } } public override string MCGalaxy_Version { get { return Server.Version; } } public override string name { get { return "CorePlugin"; } } diff --git a/MCGalaxy/CorePlugin/NotesPlugin.cs b/MCGalaxy/CorePlugin/NotesPlugin.cs index b36b96ff6..f0f2818af 100644 --- a/MCGalaxy/CorePlugin/NotesPlugin.cs +++ b/MCGalaxy/CorePlugin/NotesPlugin.cs @@ -20,7 +20,7 @@ using MCGalaxy.Events; namespace MCGalaxy.Core { - public sealed class NotesPlugin : Plugin_Simple { + public sealed class NotesPlugin : Plugin { public override string creator { get { return Server.SoftwareName + " team"; } } public override string MCGalaxy_Version { get { return Server.Version; } } public override string name { get { return "Core_NotesPlugin"; } } diff --git a/MCGalaxy/Server/Logger.cs b/MCGalaxy/Server/Logger.cs index d9a2bde5c..8c023c13a 100644 --- a/MCGalaxy/Server/Logger.cs +++ b/MCGalaxy/Server/Logger.cs @@ -16,6 +16,7 @@ permissions and limitations under the Licenses. */ using System; +using System.Reflection; using System.Text; namespace MCGalaxy { @@ -130,6 +131,18 @@ namespace MCGalaxy { try { sb.AppendLine("Message: " + ex.Message); } catch { } try { sb.AppendLine("Target: " + ex.TargetSite.Name); } catch { } try { sb.AppendLine("Trace: " + ex.StackTrace); } catch { } + + // For errors with loading plugins (e.g. missing dependancy) you get a + // Message: Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information. + // which is pretty useless by itself, so check specifically for this case + try { + ReflectionTypeLoadException refEx = ex as ReflectionTypeLoadException; + if (refEx == null) return; + + sb.AppendLine("## Loader exceptions ##"); + foreach (Exception loadEx in refEx.LoaderExceptions) + DescribeError(loadEx, sb); + } catch { } } } } \ No newline at end of file