Update service exception handling

I didn't find the bug...
This commit is contained in:
Noi 2022-03-22 00:08:40 -07:00
parent 021def4f88
commit 3d4add3581
2 changed files with 3 additions and 2 deletions

View file

@ -55,7 +55,8 @@ class BirthdayRoleUpdate : BackgroundService {
exceptions.Add(ex); exceptions.Add(ex);
} }
} }
if (exceptions.Count != 0) throw new AggregateException(exceptions); if (exceptions.Count > 1) throw new AggregateException("Unhandled exceptions occurred when processing birthdays.", exceptions);
else if (exceptions.Count == 1) throw new Exception("An unhandled exception occurred when processing a birthday.", exceptions[0]);
} }
/// <summary> /// <summary>

View file

@ -64,7 +64,7 @@ class ShardBackgroundWorker : IDisposable {
_tickCount++; _tickCount++;
await service.OnTick(_tickCount, _workerCanceller.Token).ConfigureAwait(false); await service.OnTick(_tickCount, _workerCanceller.Token).ConfigureAwait(false);
} catch (Exception ex) when (ex is not TaskCanceledException) { } catch (Exception ex) when (ex is not TaskCanceledException) {
Instance.Log(nameof(WorkerLoop), $"{CurrentExecutingService} encountered an exception:\n" + ex.ToString()); Instance.Log(CurrentExecutingService, ex.ToString());
} }
} }
CurrentExecutingService = null; CurrentExecutingService = null;