Merge pull request #2 from NoiTheCat/loading-fixes
Fixes a major issue that prevents external assemblies from loading. And a minor improvement to certain error messages.
This commit is contained in:
commit
0ee43d46b0
2 changed files with 4 additions and 7 deletions
|
@ -17,7 +17,7 @@ static class ModuleLoader {
|
||||||
foreach (var file in conf.Assemblies) {
|
foreach (var file in conf.Assemblies) {
|
||||||
Assembly? a = null;
|
Assembly? a = null;
|
||||||
try {
|
try {
|
||||||
a = Assembly.LoadFile(path + file);
|
a = Assembly.LoadFrom(path + file);
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
Console.WriteLine("An error occurred when attempting to load a module assembly.");
|
Console.WriteLine("An error occurred when attempting to load a module assembly.");
|
||||||
Console.WriteLine($"File: {file}");
|
Console.WriteLine($"File: {file}");
|
||||||
|
|
|
@ -86,13 +86,10 @@ class ModuleStateService : Service {
|
||||||
var state = await module.CreateGuildStateAsync(guild.Id, guildConf[module.Name]!);
|
var state = await module.CreateGuildStateAsync(guild.Id, guildConf[module.Name]!);
|
||||||
newStates.Add(t, state);
|
newStates.Add(t, state);
|
||||||
} catch (ModuleLoadException ex) {
|
} 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;
|
return false;
|
||||||
} catch (Exception ex) when (ex is not ModuleLoadException) {
|
} catch (Exception ex) {
|
||||||
Log("Unhandled exception while initializing guild state for module:\n" +
|
Log($"Unhandled exception from {module.Name} while creating guild state for {guild.Name}:\n{ex}");
|
||||||
$"Module: {module.Name} | " +
|
|
||||||
$"Guild: {guild.Id} ({BotClient.DiscordClient.GetGuild(guild.Id)?.Name ?? "unknown name"})\n" +
|
|
||||||
$"```\n{ex}\n```");
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue