This is similar to the question I asked in this post How do I manually create an instance of reqwest::Response?
In the mock client I am writing for an integration test, I will like to seed the client with response for error cases and in such situation I want an error to be returned. That is given this trait
#[async_trait]
impl HttpClient for MockClient {
async fn send_request(&self, path: String) -> Result<Response, Error> {
self.res_req.get(path).unwrap()
}
}
I want the send_request
to return the error which is reqwest::Error
. Problem now is, it seems there is no easy way to manually construct an instance of reqwest::Error
.
Looking at the documentation here reqwest::Error - Rust I could not see any straight forward way.
Any ideas?