added first_error for asyncio task groups

This commit is contained in:
TPV committed 2026-07-27 10:27:57 -07:00
1 parent b6cd692258
commit 99e68b1fa9
1 file changed
+6 -1
+6 -1
View File
@@ -556,7 +556,12 @@ async def retry_failed_pages(
def first_error(group_exc: BaseExceptionGroup) -> BaseException:
"""Return the first leaf exception of a possibly nested exception group."""
"""Return a leaf exception of a possibly nested group, preferring an
unexpected one so a real bug is never masked by a routine network error."""
_, unexpected = group_exc.split(EXPECTED_TASK_ERRORS)
if unexpected is not None:
group_exc = unexpected
error = group_exc.exceptions[0]
while isinstance(error, BaseExceptionGroup):
error = error.exceptions[0]