Merge pull request #2 from florianjacob/fix-statuscode-error
Throw StatusCode error if http request was not successful
This commit is contained in:
commit
f9c30c7052
@ -243,18 +243,22 @@ impl ToTokens for Api {
|
|||||||
#[allow(unused_variables)]
|
#[allow(unused_variables)]
|
||||||
fn future_from(http_response: ::http::Response<Vec<u8>>)
|
fn future_from(http_response: ::http::Response<Vec<u8>>)
|
||||||
-> Box<_Future<Item = Self, Error = Self::Error>> {
|
-> Box<_Future<Item = Self, Error = Self::Error>> {
|
||||||
#extract_headers
|
if http_response.status().is_success() {
|
||||||
|
#extract_headers
|
||||||
|
|
||||||
#deserialize_response_body
|
#deserialize_response_body
|
||||||
.and_then(move |response_body| {
|
.and_then(move |response_body| {
|
||||||
let response = Response {
|
let response = Response {
|
||||||
#response_init_fields
|
#response_init_fields
|
||||||
};
|
};
|
||||||
|
|
||||||
Ok(response)
|
Ok(response)
|
||||||
});
|
});
|
||||||
|
|
||||||
Box::new(future_response)
|
Box::new(future_response)
|
||||||
|
} else {
|
||||||
|
Box::new(::futures::future::err(::ruma_api::Error::StatusCode(http_response.status().clone())))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user