src/client/http_client.rs - download: fix error handling

This commit is contained in:
Dietmar Maurer 2019-06-25 12:43:55 +02:00
parent 45db6f89e1
commit 81820b0d4d

View File

@ -224,16 +224,22 @@ impl HttpClient {
client.request(req) client.request(req)
.map_err(Error::from) .map_err(Error::from)
.and_then(|resp| { .and_then(|resp| {
let status = resp.status();
let _status = resp.status(); // fixme: ?? if !status.is_success() {
future::Either::A(
resp.into_body() HttpClient::api_response(resp)
.map_err(Error::from) .and_then(|_| { bail!("unknown error"); })
.for_each(move |chunk| { )
output.write_all(&chunk)?; } else {
Ok(()) future::Either::B(
}) resp.into_body()
.map_err(Error::from)
.for_each(move |chunk| {
output.write_all(&chunk)?;
Ok(())
})
)
}
}) })
}) })
} }