Improve GuildState error logging

This commit is contained in:
Noi 2022-08-08 20:44:20 -07:00
parent cf5db191dc
commit a1d86355cd

View 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;
} }
} }