Skip to content

Commit 9a932d2

Browse files
committed
Handle bad errors before waiting for ready
1 parent a90154d commit 9a932d2

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

postgres-tokio/src/lib.rs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -324,13 +324,11 @@ impl Connection {
324324
fn ready_err<T>(self, body: ErrorResponseBody<Vec<u8>>) -> BoxFuture<T, Error>
325325
where T: 'static + Send
326326
{
327-
self.ready(DbError::new(&mut body.fields()))
328-
.and_then(|(e, s)| {
329-
match e {
330-
Ok(e) => Err(Error::Db(Box::new(e), s)),
331-
Err(e) => Err(Error::Io(e)),
332-
}
333-
})
327+
DbError::new(&mut body.fields())
328+
.map_err(Error::Io)
329+
.into_future()
330+
.and_then(|e| self.ready(e))
331+
.and_then(|(e, s)| Err(Error::Db(Box::new(e), s)))
334332
.boxed()
335333
}
336334

0 commit comments

Comments
 (0)