-
Notifications
You must be signed in to change notification settings - Fork 4
Questions about the ExceptionGroup API #6
Comments
re 1: There's a common pattern to extract the error message: re 2: I'd say keep it simple; users can simply build a list of errors and pass it to the constructor. Disallowing empty ExceptionGroups seems like more work for no particularly good reason. re 3: I think we should. The only way to fix this is to somehow validate the ExceptionGroup just before raising it (we could do that, theoretically, in the interpreter). But that would mean than instead of getting an re 4: IMO |
re 2: I think we need an API for adding exceptions into an existing exception group anyway, for when we have to merge new exceptions into the unhandled exceptions at the end of a try. re 3: I think so too. The only other option I can think of is that "raise ExceptionGroup()" is a NOOP. But that's also weird and probably surprising (you expected to terminate execution here, otherwise the raise would be conditional). |
Right.
Yeah, if I'd see that |
Hm... I think users won't be constructing these manually much, and I think internally we'd just end up calling |
I had to read this several times and I'm still not sure what you're saying. I think you're saying that an ExceptionGroup, once created, cannot be expanded (or shrunk, I suppose), but that we'll allow users to write |
Honestly I think we should try to write up the full API for ExceptionGroup -- I expect there will be various surprises. |
Yes, that's exactly what I meant. I admit the quoted paragraph isn't clearly written, sigh.
I agree, it's time to define it. It might also affect the proposed |
Our experimental implementation does this:
I don't think the interpreter will ever need to create empty exception groups (projec/split return Py_None rather than creating an empty group).
|
I'm closing this because we have established the API by now - most of this discussion is very out of date. |
Uh oh!
There was an error while loading. Please reload this page.
Should
ExceptionGroup.__init__
have a message argument? Should it be the first argument or keyword-only?Should we allow creating an empty
ExceptionGroup
and allow adding exceptions to it?Should we allow raising an empty
ExceptionGroup
?Should
ExceptionGroup.__init__
accept*errors: ExceptionGroup
orerrors: Iterable[ExceptionGroup]
?The text was updated successfully, but these errors were encountered: