Erisa/Cliptok

Todo: Make UnpackLogConfigAsync more resilient

Closed this issue · 2 comments

See #214

If something goes wrong in UnpackLogConfigAsync it doesn't seem to log the error and the bot continues execution in a degraded state.

I don't think the exception was swallowed, it's more like it isn't shown in the Cliptok log thread because well.. it can't be, since log channel helper isn't ready yet.

[2024-08-11 00:26:30 +01:00] [Error] Event handler exception for event "DSharpPlus.EventArgs.SessionCreatedEventArgs" thrown from "System.Threading.Tasks.Task OnReady(DSharpPlus.DiscordClient, DSharpPlus.EventArgs.SessionCreatedEventArgs)" (defined in "Cliptok.Events.ReadyEvent").
System.Exception: Exception of type 'System.Exception' was thrown.
   at Cliptok.Helpers.LogChannelHelper.UnpackLogConfigAsync(ConfigJson config) in C:\Users\Erisa\Work\Cliptok\Helpers\LogChannelHelper.cs:line 18
   at Cliptok.Events.ReadyEvent.OnReady(DiscordClient client, SessionCreatedEventArgs _) in C:\Users\Erisa\Work\Cliptok\Events\ReadyEvent.cs:line 13
   at DSharpPlus.AsyncEvents.AsyncEvent`2.<>c__DisplayClass8_0.<<InvokeAsync>b__0>d.MoveNext()

since this is part of OnReady, we can try/catch and either throw an error in another channel or panic and quit the bot.

we can try/catch and either throw an error in another channel or panic and quit the bot.

The latter was chosen. Between this and f8933a9, the problem should be largely resolved.