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

Make request timeouts a top-level error #287

Open
KodrAus opened this issue Dec 7, 2017 · 1 comment
Open

Make request timeouts a top-level error #287

KodrAus opened this issue Dec 7, 2017 · 1 comment

Comments

@KodrAus
Copy link
Member

KodrAus commented Dec 7, 2017

Related to #266

reqwest has a specific error variant for timeouts. We could surface methods on ClientError that can be used to determine whether or not the error is due to a timeout:

let response = client.search::<MyType>().send;

match response {
    Ok(docs) => { .. },
    Err(Error::Api(ApiError::IndexNotFound { .. })) => { .. },
    Err(Error::Client(err)) if err.is_timeout() => { .. },
    _ => { .. }
}

It's introducing a bit of a different paradigm for dealing with variants on the client error, but I think this is ok. It's convenient to be able to pull properties out of API erorrs, like the index name and use that property to create the index.

@KodrAus
Copy link
Member Author

KodrAus commented Dec 11, 2017

Hmm, looks like reqwest currently doesn't make it easy to determine whether an error was because of a timeout (see seanmonstar/reqwest#229).

This will also depend on #290 so we can properly interrogate captured Errors and downcast them.

@KodrAus KodrAus modified the milestones: 0.20.x, Future Dec 11, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant