Skip to content

Commit fdbd3fd

Browse files
lobsterkatieandrewshie-sentry
authored andcommitted
ref(grouping): Consolidate main exception id override logic (#97541)
This is a small refactor to pull all the logic for overriding the `main_exception_id` event property into one place.
1 parent 5b7aae6 commit fdbd3fd

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

src/sentry/grouping/strategies/newstyle.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -639,11 +639,9 @@ def chained_exception(
639639
# exceptions. Either way, we need to wrap our exception components in a chained exception component.
640640
exception_components_by_variant: dict[str, list[ExceptionGroupingComponent]] = {}
641641

642-
# Check for cases in which we want to switch the `main_exception_id` in order to use a different
642+
# Handle cases in which we want to switch the `main_exception_id` in order to use a different
643643
# exception than normal for the event title
644-
main_exception_id = determine_main_exception_id(exceptions)
645-
if main_exception_id:
646-
event.data["main_exception_id"] = main_exception_id
644+
_maybe_override_main_exception_id(event, exceptions)
647645

648646
for exception in exceptions:
649647
for variant_name, component in exception_components_by_exception[id(exception)].items():
@@ -897,11 +895,12 @@ def react_error_with_cause(exceptions: list[SingleException]) -> int | None:
897895
]
898896

899897

900-
def determine_main_exception_id(exceptions: list[SingleException]) -> int | None:
898+
def _maybe_override_main_exception_id(event: Event, exceptions: list[SingleException]) -> None:
901899
main_exception_id = None
902900
for func in MAIN_EXCEPTION_ID_FUNCS:
903901
main_exception_id = func(exceptions)
904902
if main_exception_id is not None:
905903
break
906904

907-
return main_exception_id
905+
if main_exception_id:
906+
event.data["main_exception_id"] = main_exception_id

0 commit comments

Comments
 (0)