Skip to content

Commit f8ef05e

Browse files
committed
Re-order error collection to not raise ExceptionGroup in case of 1 error
1 parent ac86d9d commit f8ef05e

File tree

1 file changed

+13
-8
lines changed

1 file changed

+13
-8
lines changed

tests/utils_for_qmod.py

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -50,14 +50,19 @@ def inner_qmod(*args: Any, **kwargs: Any) -> Any:
5050
# prepend all the errors from `compare_qmods`, so that `actions/send_qmod_slack_notification` will have a simpler regex
5151
comparison_errors = _compare_qmods(qmods_before, qmods_after)
5252

53-
if comparison_errors:
54-
if error:
55-
comparison_errors.insert(0, error)
56-
raise StrippedExceptionGroup(
57-
"Main test + qmod compare errors", comparison_errors
58-
)
59-
elif error:
60-
raise strip_inners_from_exception(error)
53+
if comparison_errors or error:
54+
all_errors = []
55+
if error is not None:
56+
# put error from `func` first
57+
all_errors.append(error)
58+
all_errors.extend(comparison_errors)
59+
60+
if len(all_errors) == 1:
61+
raise strip_inners_from_exception(all_errors[0])
62+
else:
63+
raise StrippedExceptionGroup(
64+
"Main test + qmod compare errors", all_errors
65+
)
6166

6267
return result
6368

0 commit comments

Comments
 (0)