Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hide MultiErrors #132

Open
mehaase opened this issue Feb 28, 2020 · 0 comments
Open

Hide MultiErrors #132

mehaase opened this issue Feb 28, 2020 · 0 comments

Comments

@mehaase
Copy link
Contributor

mehaase commented Feb 28, 2020

Several of the APIs in this library create a "hidden" nursery that runs the connection's background task. This has the surprising side effect that something that looks like single-task code can actually raise a MultiError. Nathaniel has a good thread describing this. I'll just steal a snippet to illustrate the problem here:

async with open_websocket("https://...") as ws:
    raise ValueError

but if open_websocket has a nursery hidden inside it, then you'll get a MultiError([ValueError]) instead of a ValueError, and that's going to surprise people, because it's mostly an implementation detail that open_websocket creates a nursery.

The proposed solution is to design the library to avoid raising exceptions on the background task. This would allow us to catch MultiError in the hidden nursery, unwrap the nested exception, and raise it to the caller. If the background task does raise an error, then we wrap* the entire MultiError inside of a new class TrioWebsocketInternalError. This wrapper class is a signal to the caller that the bug is in this library, not in their code.

*Nathaniel's post suggests that the internal error either is-a or has-a MultiError. We can also look at TrioInternalError for inspiration.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant