Message410942
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? |
|
Date |
User |
Action |
Args |
2022-01-19 13:13:20 | petr.viktorin | set | recipients:
+ petr.viktorin, iritkatriel |
2022-01-19 13:13:20 | petr.viktorin | set | messageid: <1642598000.53.0.498228556289.issue46431@roundup.psfhosted.org> |
2022-01-19 13:13:20 | petr.viktorin | link | issue46431 messages |
2022-01-19 13:13:20 | petr.viktorin | create | |
|