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,6 +243,7 @@ impl ToTokens for Api {
|
||||
#[allow(unused_variables)]
|
||||
fn future_from(http_response: ::http::Response<Vec<u8>>)
|
||||
-> Box<_Future<Item = Self, Error = Self::Error>> {
|
||||
if http_response.status().is_success() {
|
||||
#extract_headers
|
||||
|
||||
#deserialize_response_body
|
||||
@ -255,6 +256,9 @@ impl ToTokens for Api {
|
||||
});
|
||||
|
||||
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