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

Commit

Permalink
Merge pull request #43 from neos-modding-group/ReflectionTypeLoadExce…
Browse files Browse the repository at this point in the history
…ption-logging

Additional logging for ReflectionTypeLoadException
  • Loading branch information
zkxs authored Jul 2, 2022
2 parents a4931f0 + 464cc16 commit 0bd2f08
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 4 deletions.
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

0 comments on commit 0bd2f08

Please sign in to comment.