Skip to content

Commit 16179d8

Browse files
committed
Conditionally add the terminal key
1 parent dec8f34 commit 16179d8

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

src/Sentry/SentryExceptionExtensions.cs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public static void AddSentryContext(this Exception ex, string name, IReadOnlyDic
3434
/// <param name="handled">An optional flag indicating whether the exception was handled by the mechanism.</param>
3535
/// <param name="terminal">An optional flag indicating whether the exception is considered terminal.</param>
3636
public static void SetSentryMechanism(this Exception ex, string type, string? description = null,
37-
bool? handled = null, bool terminal = true)
37+
bool? handled = null, bool? terminal = null)
3838
{
3939
ex.Data[Mechanism.MechanismKey] = type;
4040

@@ -56,6 +56,13 @@ public static void SetSentryMechanism(this Exception ex, string type, string? de
5656
ex.Data[Mechanism.HandledKey] = handled;
5757
}
5858

59-
ex.Data[Mechanism.TerminalKey] = terminal;
59+
if (terminal == null)
60+
{
61+
ex.Data.Remove(Mechanism.TerminalKey);
62+
}
63+
else
64+
{
65+
ex.Data[Mechanism.TerminalKey] = terminal;
66+
}
6067
}
6168
}

0 commit comments

Comments
 (0)