Skip to content
This repository has been archived by the owner on Feb 28, 2024. It is now read-only.

Commit

Permalink
Additional logging for ReflectionTypeLoadException
Browse files Browse the repository at this point in the history
Also, the VS code cleanup disliked some imports in EnumerableInjector.
  • Loading branch information
zkxs committed Jul 2, 2022
1 parent a4931f0 commit b46ceb8
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
20 changes: 20 additions & 0 deletions NeosModLoader/ModLoader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using System.IO;
using System.Linq;
using System.Reflection;
using System.Text;

namespace NeosModLoader
{
Expand Down Expand Up @@ -65,6 +66,25 @@ internal static void LoadMods()
RegisterMod(loaded);
}
}
catch (ReflectionTypeLoadException reflectionTypeLoadException)
{
// this exception type has some inner exceptions we must also log to gain any insight into what went wrong
StringBuilder sb = new();
sb.AppendLine(reflectionTypeLoadException.ToString());
foreach (Exception loaderException in reflectionTypeLoadException.LoaderExceptions)
{
sb.AppendLine($"Loader Exception: {loaderException.Message}");
if (loaderException is FileNotFoundException fileNotFoundException)
{
if (!string.IsNullOrEmpty(fileNotFoundException.FusionLog))
{
sb.Append(" Fusion Log:\n ");
sb.AppendLine(fileNotFoundException.FusionLog);
}
}
}
Logger.ErrorInternal($"ReflectionTypeLoadException initializing mod from {mod.File}:\n{sb}");
}
catch (Exception e)
{
Logger.ErrorInternal($"Unexpected exception initializing mod from {mod.File}:\n{e}");
Expand Down
3 changes: 0 additions & 3 deletions NeosModLoader/Utility/EnumerableInjector.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace NeosModLoader.Utility
{
Expand Down

0 comments on commit b46ceb8

Please sign in to comment.