Skip to content

Commit 4d239a5

Browse files
authored
fix: log only if transaction exists (#2862)
1 parent 36601a0 commit 4d239a5

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/Sentry/Internal/Hub.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -437,12 +437,12 @@ SentryId IHubEx.CaptureEventInternal(SentryEvent evt, Hint? hint, Scope? scope)
437437
actualScope.LastEventId = id;
438438
actualScope.SessionUpdate = null;
439439

440-
if (evt.HasTerminalException())
440+
if (evt.HasTerminalException() && actualScope.Transaction is { } transaction)
441441
{
442442
// Event contains a terminal exception -> finish any current transaction as aborted
443443
// Do this *after* the event was captured, so that the event is still linked to the transaction.
444444
_options.LogDebug("Ending transaction as Aborted, due to unhandled exception.");
445-
actualScope.Transaction?.Finish(SpanStatus.Aborted);
445+
transaction.Finish(SpanStatus.Aborted);
446446
}
447447

448448
return id;

0 commit comments

Comments
 (0)