---
source: https://iinventedlight.com/library/notes/python-exception-groups.md
title: "Handle several errors at once with ExceptionGroup and except*"
license: CC-BY-4.0
license_url: https://creativecommons.org/licenses/by/4.0/
source_license: "PSF-2.0 (Python docs); Public-Domain (Python PEPs); prose restates cited source lines in own words"
license_family: mixed-green
attribution: "Summary by iinventedlight (AI-assisted). Sources: Python docs, Built-in Exceptions; Python PEPs, PEP 654 – Exception Groups and except*. PSF-2.0; Public-Domain."
author: "iinventedlight (synthesis of cited sources); text drafted with AI assistance"
date: 2026-11-19
status: published
approved_by: "Cole Withington, 2026-11-20 13:14 PT: \"Publish the full batch and rewrite the 6 live notes\""
checked_on: 2026-11-19
as_of: 2026-11-19
confidence: medium
untested: "Not reproduced (2026-11-19). Official docs and source files were read; no test suite, server, or API call was run for this note."
category: coding-references
topic_area: "code-python: ExceptionGroup and except* in Python"
tags: [python, ExceptionGroup, BaseExceptionGroup, except*, exceptions, pep-654]
client: Librarian
sources:
  - id: S1
    title: "Built-in Exceptions"
    publisher: Python docs
    url: https://docs.python.org/3/library/exceptions.html
    accessed: 2026-11-19
    license: "PSF-2.0"
  - id: S2
    title: "PEP 654 – Exception Groups and except*"
    publisher: Python PEPs
    url: https://peps.python.org/pep-0654/
    accessed: 2026-11-19
    license: "Public-Domain"
---
# Handle several errors at once with ExceptionGroup and except*
**Answer:** Use `ExceptionGroup` when one operation needs to raise several unrelated errors together. Both `ExceptionGroup` and `BaseExceptionGroup` wrap the exceptions in the sequence `excs`. The `msg` parameter must be a string. Handle a group with `except*`, which matches their subgroups based on the types of the contained exceptions. ## The two classes

`BaseExceptionGroup` extends `BaseException` and can wrap any exception. `ExceptionGroup` extends `Exception` and can only wrap subclasses of `Exception`. That is why `except Exception` catches an `ExceptionGroup` but not `BaseExceptionGroup`. If every contained exception is an `Exception` instance, the `BaseExceptionGroup` constructor returns an `ExceptionGroup` instead, so the selection can be automatic. The `ExceptionGroup` constructor raises a `TypeError` if any contained exception is not an `Exception` subclass.

PEP 654 is the design document. In that text, when we refer to an exception group, we mean either an `ExceptionGroup` or a `BaseExceptionGroup`. A nested group is a tree of exceptions. The leaves are plain exceptions, and each internal node is a moment when the program grouped unrelated exceptions and raised them together. `subgroup(condition)` returns a group with the same metadata and nested structure, but only those exceptions for which the condition is true.

| ExceptionGroup | BaseExceptionGroup |
|---|---|
| `ExceptionGroup` | Wrap `Exception` subclasses |
| `BaseExceptionGroup` | Wrap any `BaseException` subclass |
| `except*` | Match subgroups by contained types |
| `except Exception` | Catches an `ExceptionGroup`, not a `BaseExceptionGroup` |
| `subgroup` | Same metadata, fewer nested exceptions |

## See also

- [python-exceptions-hierarchy](https://iinventedlight.com/library/notes/python-exceptions-hierarchy/)
- [python-asyncio-awaitables](https://iinventedlight.com/library/notes/python-asyncio-awaitables/)
- [python-contextlib](https://iinventedlight.com/library/notes/python-contextlib/)

## Claims

- id: C1
  claim: except Exception catches ExceptionGroup but not BaseExceptionGroup.
  source: S1
  evidence: "except Exception catches an ExceptionGroup but not BaseExceptionGroup"

- id: C3
  claim: except* matches subgroups by the types of the contained exceptions.
  source: S1
  evidence: "except* , which matches their subgroups based on the types"

- id: C4
  claim: ExceptionGroup rejects nested exceptions that are not Exception instances.
  source: S2
  evidence: "The ExceptionGroup constructor raises a TypeError"

## Sources

- [S1] Built-in Exceptions. Python docs. https://docs.python.org/3/library/exceptions.html . License: PSF-2.0. Accessed 2026-11-19.

- [S2] PEP 654 – Exception Groups and except*. Python PEPs. https://peps.python.org/pep-0654/ . License: Public-Domain. Accessed 2026-11-19.

License: this note is CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Summary by iinventedlight (AI-assisted). Sources: Python docs, Built-in Exceptions; Python PEPs, PEP 654 – Exception Groups and except*. PSF-2.0; Public-Domain. Text was condensed and changed from the originals.

---

Agents: [/agents.md](/agents.md) | [/.well-known/agent-library.json](/.well-known/agent-library.json).
