This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author petr.viktorin
Recipients iritkatriel, petr.viktorin
Date 2022-01-19.13:13:20
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1642598000.53.0.498228556289.issue46431@roundup.psfhosted.org>
In-reply-to
Content
I want to test a web application by crawling every reachable page. If an error occurs, I need to keep track of the page the error occured at (and additional info like what links were followed to get to the page, so a `__note__` string isn't enough). This info is in an object I'll call Task.
To use the improvements from PEP 654 but also keep extra info, I tried to make a subclass of ExceptionGroup:

```python
class MultiError(ExceptionGroup):
    def __init__(self, failed_tasks):
        super.__init__(
            f"{len(tasks)} tasks failed",
            [t.exception for t in failed_tasks],
        )
        self.tasks = tasks
        # ... and set __note__ on each exception for nice tracebacks
```

but this fails with a rather opaque message:

```python
>>> class Task: exception = AssertionError() # enough of a Task for this example 
... 
>>> MultiError([Task(), Task()])
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: function takes exactly 2 arguments (1 given)
```

Knowing about `__new__` and following a note in the docs, I'm able to fix this, but It's not obvious.
Before suggesting stuff, I'll ask: Am I doing something weird, or should this be made easier/more obvious?


Another issue I ran into: the list of exceptions is stored in the publicly-named but undocumented attribute `exceptions`. Am I allowed to use it?
History
Date User Action Args
2022-01-19 13:13:20petr.viktorinsetrecipients: + petr.viktorin, iritkatriel
2022-01-19 13:13:20petr.viktorinsetmessageid: <1642598000.53.0.498228556289.issue46431@roundup.psfhosted.org>
2022-01-19 13:13:20petr.viktorinlinkissue46431 messages
2022-01-19 13:13:20petr.viktorincreate