async_client/error: dont swallow response error in `AsyncClient::send`

master
Devin R 2020-04-16 15:20:36 -04:00
parent d91de818ac
commit c0e1ff1734
2 changed files with 5 additions and 2 deletions

View File

@ -827,7 +827,7 @@ impl AsyncClient {
let body = response.bytes().await?.as_ref().to_owned(); let body = response.bytes().await?.as_ref().to_owned();
let http_response = http_response.body(body).unwrap(); let http_response = http_response.body(body).unwrap();
let response = <Request::Response as Outgoing>::Incoming::try_from(http_response) let response = <Request::Response as Outgoing>::Incoming::try_from(http_response)
.expect("Can't convert http response into ruma response"); .map_err(|e| Error::LoginError(format!("{:?}", e)))?;
Ok(response) Ok(response)
} }

View File

@ -47,9 +47,12 @@ pub enum Error {
#[error("can't convert between ruma_client_api and hyper types.")] #[error("can't convert between ruma_client_api and hyper types.")]
IntoHttp(RumaIntoHttpError), IntoHttp(RumaIntoHttpError),
#[cfg(feature = "encryption")] #[cfg(feature = "encryption")]
/// An error occured durring a E2EE operation. /// An error occurred during a E2EE operation.
#[error(transparent)] #[error(transparent)]
OlmError(#[from] OlmError), OlmError(#[from] OlmError),
/// An error occurred during log in.
#[error("can't login {0}.")]
LoginError(String),
} }
impl From<RumaResponseError<RumaClientError>> for Error { impl From<RumaResponseError<RumaClientError>> for Error {