Built-in Exceptions

ExceptionGroup — exception class

Container for multiple Exception instances, often produced by concurrent tasks. Construct with a string message and a nonempty sequence of ordinary exceptions. except* selects matching leaves while preserving nested structure; a plain except ExceptionGroup catches the whole group. It cannot contain SystemExit or other BaseException-only signals. Catch ExceptionGroup when this category is the recovery boundary; do not rely on the exact human-readable message.

Formal Syntax & Structure

python syntaxpython
ExceptionGroup

Return Value

type

The class object ExceptionGroup; this reference documents the class identity, not a universal constructor signature.

Working Example

Example Snippetpython
try:    raise ExceptionGroup("batch", [ValueError("bad"), TypeError("type")])except ExceptionGroup as error:    print(type(error).__name__)
Python Reference