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

Commit

Permalink
fix: add a try catch for loading one assembly.
Browse files Browse the repository at this point in the history
  • Loading branch information
ArchiDog1998 committed Apr 11, 2023
1 parent c89c16d commit 8d516ee
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions RotationSolver/Updaters/RotationUpdater.cs
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,21 @@ public static async void GetAllCustomRotations()
if (hasDownload) LoadRotationsFromLocal(relayFolder);
}

private static Assembly LoadOne(string filePath)
{
try
{
var assembly = RotationHelper.LoadFrom(filePath);
PluginLog.Log("Successfully loaded " + assembly.FullName);
return assembly;
}
catch (Exception ex)
{
PluginLog.Log("Failed to load " + filePath, ex);
}
return null;
}

private static void LoadRotationsFromLocal(string relayFolder)
{
var directories = Service.Config.OtherLibs
Expand All @@ -97,9 +112,9 @@ private static void LoadRotationsFromLocal(string relayFolder)
var assemblies = from dir in directories
where Directory.Exists(dir)
from l in Directory.GetFiles(dir, "*.dll")
select RotationHelper.LoadFrom(l);

PluginLog.Log("Try to load rotations from these assemblies.\n" + string.Join('\n', assemblies.Select(a => "- " + a.FullName)));
select LoadOne(l) into a
where a != null
select a;

AuthorHashes = new SortedList<string, string>(
(from a in assemblies
Expand Down

0 comments on commit 8d516ee

Please sign in to comment.