From cf5db191dce30147cc7f978fed55b892da536fc4 Mon Sep 17 00:00:00 2001 From: Noi Date: Mon, 8 Aug 2022 20:36:39 -0700 Subject: [PATCH 1/2] Fix module dependencies not loading with module assembly --- ModuleLoader.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ModuleLoader.cs b/ModuleLoader.cs index cacad90..e7a46d7 100644 --- a/ModuleLoader.cs +++ b/ModuleLoader.cs @@ -17,7 +17,7 @@ static class ModuleLoader { foreach (var file in conf.Assemblies) { Assembly? a = null; try { - a = Assembly.LoadFile(path + file); + a = Assembly.LoadFrom(path + file); } catch (Exception ex) { Console.WriteLine("An error occurred when attempting to load a module assembly."); Console.WriteLine($"File: {file}"); From a1d86355cdfeb8a73d1e61aef7375344b35f04ba Mon Sep 17 00:00:00 2001 From: Noi Date: Mon, 8 Aug 2022 20:44:20 -0700 Subject: [PATCH 2/2] Improve GuildState error logging --- Services/ModuleState/ModuleStateService.cs | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/Services/ModuleState/ModuleStateService.cs b/Services/ModuleState/ModuleStateService.cs index 33c9142..b5945e1 100644 --- a/Services/ModuleState/ModuleStateService.cs +++ b/Services/ModuleState/ModuleStateService.cs @@ -86,13 +86,10 @@ class ModuleStateService : Service { var state = await module.CreateGuildStateAsync(guild.Id, guildConf[module.Name]!); newStates.Add(t, state); } catch (ModuleLoadException ex) { - Log($"{guild.Id}: Error reading configuration regarding {module.Name}: {ex.Message}"); + Log($"{module.Name} failed to read configuration for {guild.Name}: {ex.Message}"); return false; - } catch (Exception ex) when (ex is not ModuleLoadException) { - Log("Unhandled exception while initializing guild state for module:\n" + - $"Module: {module.Name} | " + - $"Guild: {guild.Id} ({BotClient.DiscordClient.GetGuild(guild.Id)?.Name ?? "unknown name"})\n" + - $"```\n{ex}\n```"); + } catch (Exception ex) { + Log($"Unhandled exception from {module.Name} while creating guild state for {guild.Name}:\n{ex}"); return false; } }