Handle bad errors before waiting for ready

This commit is contained in:
Steven Fackler 2016-12-20 20:18:30 -08:00
parent a90154dfdb
commit 9a932d2d24

View File

@ -324,13 +324,11 @@ impl Connection {
fn ready_err<T>(self, body: ErrorResponseBody<Vec<u8>>) -> BoxFuture<T, Error> fn ready_err<T>(self, body: ErrorResponseBody<Vec<u8>>) -> BoxFuture<T, Error>
where T: 'static + Send where T: 'static + Send
{ {
self.ready(DbError::new(&mut body.fields())) DbError::new(&mut body.fields())
.and_then(|(e, s)| { .map_err(Error::Io)
match e { .into_future()
Ok(e) => Err(Error::Db(Box::new(e), s)), .and_then(|e| self.ready(e))
Err(e) => Err(Error::Io(e)), .and_then(|(e, s)| Err(Error::Db(Box::new(e), s)))
}
})
.boxed() .boxed()
} }