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

Come up with some reasonable error/result handling #1

Open
martinitus opened this issue Sep 1, 2022 · 1 comment
Open

Come up with some reasonable error/result handling #1

martinitus opened this issue Sep 1, 2022 · 1 comment

Comments

@martinitus
Copy link
Owner

The current hacks essentially unwrap and panic at various locations.
Instead it would be good to use appropriate result types.

It might be best to support only async traits that exclusively use results as return values (even for Unit returns) in their methods. Otherwise there is sort of a symmetry break when going from async trait to service back to async trait. One can see this in the generated blanket implementations let response = self.call(#request_ident::#variant_ident {#(#args),*}).await.unwrap();. Where instead of unwrapping, an error from the tower.call invocation should be mapped to the async trait result type instead.

@martinitus
Copy link
Owner Author

Another option would be to simply modify the trait to wrap the return values into Resultsimilar as async_trait turns them into Pin<Box<Future...>>. That would however also require putting the #[tower_service] on the trait implementation to achieve the same transformation there.

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