Skip to content

Commit af883d5

Browse files
committed
docs
1 parent b9b2c97 commit af883d5

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

Doc/library/exceptions.rst

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,35 @@ The following exceptions are used mostly as base classes for other exceptions.
159159

160160
.. versionadded:: 3.11
161161

162+
.. method:: subgroup(condition)
163+
164+
Return an :class:`BaseExceptionGroup` or :class:`ExceptionGroup` that
165+
contains this exception if it matches a *condition*, or ``None`` if
166+
the result is empty.
167+
168+
The condition can be an exception type or tuple of exception types, in
169+
which case the exception is checked for a match using the same check
170+
that is used in an ``except`` clause.
171+
172+
The condition can also be a callable (other than a type object) that
173+
accepts an exception as its single argument and returns true if the
174+
exception should be matched.
175+
176+
.. seealso:: :meth:`BaseExceptionGroup.subgroup`
177+
178+
.. versionadded:: 3.14
179+
180+
.. method:: split(condition)
181+
182+
Like :meth:`subgroup`, but returns the pair ``(match, rest)`` where
183+
``match`` is ``subgroup(condition)`` and ``rest`` is the remaining
184+
non-matching part (either ``None`` or an exception group wrapping
185+
this exception).
186+
187+
.. seealso:: :meth:`BaseExceptionGroup.split`
188+
189+
.. versionadded:: 3.14
190+
162191

163192
.. exception:: Exception
164193

@@ -975,6 +1004,8 @@ their subgroups based on the types of the contained exceptions.
9751004
including the top-level and any nested exception groups. If the condition is
9761005
true for such an exception group, it is included in the result in full.
9771006

1007+
.. seealso:: :meth:`BaseException.subgroup`
1008+
9781009
.. versionadded:: 3.13
9791010
``condition`` can be any callable which is not a type object.
9801011

@@ -984,6 +1015,8 @@ their subgroups based on the types of the contained exceptions.
9841015
is ``subgroup(condition)`` and ``rest`` is the remaining non-matching
9851016
part.
9861017

1018+
.. seealso:: :meth:`BaseException.split`
1019+
9871020
.. method:: derive(excs)
9881021

9891022
Returns an exception group with the same :attr:`message`, but which

0 commit comments

Comments
 (0)