Skip to content
This repository was archived by the owner on Nov 2, 2022. It is now read-only.

Commit ba7e87a

Browse files
author
Robert Schindler
committed
Improved docstring of ExceptionGroup
1 parent 2658ee0 commit ba7e87a

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

Diff for: exceptiongroup/__init__.py

+14
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,20 @@ class ExceptionGroup(BaseException):
2525
ValueError: if the exceptions and sources lists don't have the same
2626
length.
2727
28+
Handle the individual exceptions contained in a group like so::
29+
30+
try:
31+
...
32+
except ExceptionGroup as eg:
33+
for exc in eg.findall(ValueError):
34+
# Handle exc here
35+
eg = eg.remove(exc)
36+
exc = eg.find(TypeError)
37+
if exc:
38+
# Handle that as well
39+
eg = eg.remove(exc)
40+
eg.maybe_reraise()
41+
2842
"""
2943

3044
def __init__(self, message, exceptions, sources):

0 commit comments

Comments
 (0)