From a052c8331c44ff6d53e15f1e8c5b3b6464953162 Mon Sep 17 00:00:00 2001 From: Ske Date: Tue, 5 May 2020 16:42:14 +0200 Subject: [PATCH] Properly pass exceptions to Sentry --- PluralKit.Bot/Bot.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/PluralKit.Bot/Bot.cs b/PluralKit.Bot/Bot.cs index 3035908a..a7989b40 100644 --- a/PluralKit.Bot/Bot.cs +++ b/PluralKit.Bot/Bot.cs @@ -97,14 +97,16 @@ namespace PluralKit.Bot private async Task HandleError(IEventHandler handler, T evt, ILifetimeScope serviceScope, Exception exc) where T: DiscordEventArgs { - _logger.Error(exc, "Exception in bot event handler"); + // Make this beforehand so we can access the event ID for logging + var sentryEvent = new SentryEvent(exc); + + _logger.Error(exc, "Exception in bot event handler (Sentry ID: {SentryEventId})", sentryEvent.EventId); var shouldReport = exc.IsOurProblem(); if (shouldReport) { // Report error to Sentry // This will just no-op if there's no URL set - var sentryEvent = new SentryEvent(); var sentryScope = serviceScope.Resolve(); SentrySdk.CaptureEvent(sentryEvent, sentryScope);