Skip to content

Commit 58f1d69

Browse files
committed
OnReady: throw fatal error and exit program if log unpack fails
Fixes #215
1 parent d4a11cd commit 58f1d69

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

Events/ReadyEvent.cs

+11-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
using static Cliptok.Program;
1+
using System.Runtime.ExceptionServices;
2+
using static Cliptok.Program;
23

34
namespace Cliptok.Events
45
{
@@ -9,8 +10,15 @@ public static async Task OnReady(DiscordClient client, SessionCreatedEventArgs _
910

1011
homeGuild = await discord.GetGuildAsync(cfgjson.ServerID);
1112

12-
if (!LogChannelHelper.ready)
13-
await LogChannelHelper.UnpackLogConfigAsync(cfgjson);
13+
try
14+
{
15+
if (!LogChannelHelper.ready)
16+
await LogChannelHelper.UnpackLogConfigAsync(cfgjson);
17+
} catch (Exception e)
18+
{
19+
client.Logger.LogCritical(e, "Fatal error unpacking log config!");
20+
Environment.Exit(1);
21+
}
1422

1523
var fetchResult = await APIs.ServerAPI.FetchMaliciousServersList();
1624
if (fetchResult is not null)

0 commit comments

Comments
 (0)