Exception Methods
BaseExceptionGroup.derive() — exception method
Build a replacement group with the existing message and a supplied nonempty sequence of exceptions. Custom group subclasses override this hook to preserve their own type or metadata when subgroup() and split() create new groups. A direct derive() call does not perform the filtering methods’ automatic chaining and note propagation.
Formal Syntax & Structure
python syntaxpython
group.derive(excs, /)Parameters & Attributes
| Name | Type | Description |
|---|---|---|
| excs | sequence[BaseException] | Nonempty sequence of child exceptions valid for the new group. |
Return Value
BaseExceptionGroup
A group containing the supplied exceptions.
Working Example
Example Snippetpython
group = ExceptionGroup("validation", [ValueError("quantity"), TypeError("price")])result = group.derive([group.exceptions[1]])print(result.message)print(type(result.exceptions[0]).__name__)print(len(group.exceptions))