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

Additional logging for ReflectionTypeLoadException #43

Merged
merged 2 commits into from
Jul 2, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 21 additions & 1 deletion NeosModLoader/ModLoader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@
using System.IO;
using System.Linq;
using System.Reflection;
using System.Text;

namespace NeosModLoader
{
public class ModLoader
{
internal const string VERSION_CONSTANT = "1.11.0";
internal const string VERSION_CONSTANT = "1.11.1";
/// <summary>
/// NeosModLoader's version
/// </summary>
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