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

Expose legacy error kinds #162

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

richarddd
Copy link

Sometimes we might want to retry a request if for instance we have a partial write/read and server has dropped connection.
This PR allows us to match on the error kinds to determine further action.

@seanmonstar
Copy link
Member

Thanks for the PR!

I appreciate the desire to be able to handle certain error conditions (I really do!), I also am hesitant to expose the enum like so (see some thoughts in this write-up).

@richarddd
Copy link
Author

While I do agree with some points in your post, and its not a super straight forward solution, I don't fully agree that providing methods is the right way. In this case, it's about handling error scenarios, where a user is very likely to handle specific error scenarios, meaning that the match would probably have a _ => arm.
Naturally this assumption doesn't apply for all use cases or implementors but i'd argue it's better than having no way other than an hacky workaround to get the debug representation to determine the error cause :)

let error = format!("{:?}", err);
let is_send_request_error = error.ends_with("(SendRequest)");

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

Successfully merging this pull request may close these issues.

2 participants