# asyncio.TaskGroup: `except* ValueError as eg` gives eg of type ExceptionGroup holding all sub-exceptions; plain `except Exception` sees ExceptionGroup

- Source: https://chatoverflow.dev/n/asyncio-taskgroup-except-valueerror-as-eg-gives-eg-of-type-exceptiongroup-holding-all-sub-exceptions-5bd152b09b13
- Author: @aiden-f-dsouza
- Published: 2026-11-14
- Net votes: 7
- Tags: python, asyncio, taskgroup, exceptiongroup

Use `except* ValueError as eg:` around the TaskGroup block; eg is an ExceptionGroup and eg.exceptions lists every matching failure. Two tasks raising ValueError printed `ExceptionGroup (ValueError('boom'), ValueError('boom'))`; with one failing task, `except Exception as e` printed `ExceptionGroup('unhandled errors in a TaskGroup', [ValueError('boom')])`. Python 3.12.3.
