Skip to content

Commit 4390d51

Browse files
authored
Fix todo!() errors in legacy client (#28)
Replace the todo!() with relevant errors from hyper::Error
1 parent 6f96103 commit 4390d51

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

src/client/legacy.rs

+9-4
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ pub struct Error {
5858
#[derive(Debug)]
5959
enum ErrorKind {
6060
Canceled,
61+
ChannelClosed,
6162
Connect,
6263
UserUnsupportedRequestMethod,
6364
UserUnsupportedVersion,
@@ -686,7 +687,7 @@ impl<B> PoolClient<B> {
686687
) -> Poll<Result<(), Error>> {
687688
match self.tx {
688689
#[cfg(feature = "http1")]
689-
PoolTx::Http1(ref mut tx) => tx.poll_ready(cx).map_err(|_| todo!()),
690+
PoolTx::Http1(ref mut tx) => tx.poll_ready(cx).map_err(Error::closed),
690691
#[cfg(feature = "http2")]
691692
PoolTx::Http2(_) => Poll::Ready(Ok(())),
692693
}
@@ -739,23 +740,23 @@ impl<B: Body + 'static> PoolClient<B> {
739740
#[cfg(feature = "http2")]
740741
PoolTx::Http2(ref mut tx) => Either::Right(tx.send_request(req)),
741742
}
742-
.map_err(|_| todo!());
743+
.map_err(Error::tx);
743744

744745
#[cfg(feature = "http1")]
745746
#[cfg(not(feature = "http2"))]
746747
return match self.tx {
747748
#[cfg(feature = "http1")]
748749
PoolTx::Http1(ref mut tx) => tx.send_request(req),
749750
}
750-
.map_err(|_| todo!());
751+
.map_err(Error::tx);
751752

752753
#[cfg(not(feature = "http1"))]
753754
#[cfg(feature = "http2")]
754755
return match self.tx {
755756
#[cfg(feature = "http2")]
756757
PoolTx::Http2(ref mut tx) => tx.send_request(req),
757758
}
758-
.map_err(|_| todo!());
759+
.map_err(Error::tx);
759760
}
760761
/*
761762
//TODO: can we re-introduce this somehow? Or must people use tower::retry?
@@ -1456,4 +1457,8 @@ impl Error {
14561457
fn tx(src: hyper::Error) -> Self {
14571458
e!(SendRequest, src)
14581459
}
1460+
1461+
fn closed(src: hyper::Error) -> Self {
1462+
e!(ChannelClosed, src)
1463+
}
14591464
}

0 commit comments

Comments
 (0)