From f14c421e23987ae539dd00e16a6e5275e8ce7170 Mon Sep 17 00:00:00 2001 From: alyssa Date: Sat, 15 Jun 2024 23:59:38 +0900 Subject: [PATCH] fix(bot): expose errors from the per-minute scheduled task --- PluralKit.Bot/Bot.cs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/PluralKit.Bot/Bot.cs b/PluralKit.Bot/Bot.cs index c1dbb718..6b6d8107 100644 --- a/PluralKit.Bot/Bot.cs +++ b/PluralKit.Bot/Bot.cs @@ -83,9 +83,16 @@ public class Bot // This *probably* doesn't matter in practice but I jut think it's neat, y'know. var timeNow = SystemClock.Instance.GetCurrentInstant(); var timeTillNextWholeMinute = TimeSpan.FromMilliseconds(60000 - timeNow.ToUnixTimeMilliseconds() % 60000 + 250); - _periodicTask = new Timer(_ => + _periodicTask = new Timer(async _ => { - var __ = UpdatePeriodic(); + try + { + await UpdatePeriodic(); + } + catch (Exception e) + { + _logger.Error(e, "failed to run once-per-minute scheduled task"); + } }, null, timeTillNextWholeMinute, TimeSpan.FromMinutes(1)); }