async_client: name associated error type in AsyncClient::send

master
Devin R 2020-04-16 16:39:44 -04:00
parent c0e1ff1734
commit 07b7cbfe4e
3 changed files with 8 additions and 12 deletions

View File

@ -24,7 +24,7 @@ async-trait = "0.1.30"
# Ruma dependencies
js_int = "0.1.4"
ruma-api = "0.15.0"
ruma-api = "0.15.1"
ruma-client-api = { git = "https://github.com/matrix-org/ruma-client-api/", version = "0.7.0" }
ruma-events = { git = "https://github.com/matrix-org/ruma-events", version = "0.18.0" }
ruma-identifiers = "0.14.1"

View File

@ -754,7 +754,7 @@ impl AsyncClient {
}
}
async fn send<Request: Endpoint + std::fmt::Debug>(
async fn send<Request: Endpoint<ResponseError = ruma_client_api::Error> + std::fmt::Debug>(
&self,
request: Request,
) -> Result<<Request::Response as Outgoing>::Incoming>
@ -815,21 +815,20 @@ impl AsyncClient {
trace!("Got response: {:?}", response);
let status = response.status();
let mut http_response = HttpResponse::builder().status(status);
let headers = http_response.headers_mut().unwrap();
let mut http_builder = HttpResponse::builder().status(status);
let headers = http_builder.headers_mut().unwrap();
for (k, v) in response.headers_mut().drain() {
if let Some(key) = k {
headers.insert(key, v);
}
}
let body = response.bytes().await?.as_ref().to_owned();
let http_response = http_response.body(body).unwrap();
let response = <Request::Response as Outgoing>::Incoming::try_from(http_response)
.map_err(|e| Error::LoginError(format!("{:?}", e)))?;
let http_response = http_builder.body(body).unwrap();
Ok(response)
Ok(<Request::Response as Outgoing>::Incoming::try_from(
http_response,
)?)
}
/// Send a room message to the homeserver.

View File

@ -50,9 +50,6 @@ pub enum Error {
/// An error occurred during a E2EE operation.
#[error(transparent)]
OlmError(#[from] OlmError),
/// An error occurred during log in.
#[error("can't login {0}.")]
LoginError(String),
}
impl From<RumaResponseError<RumaClientError>> for Error {