From 4390d517b5ce15384808fe471e95dd737662bacc Mon Sep 17 00:00:00 2001 From: Garrett Thornburg Date: Mon, 22 May 2023 07:09:46 -0700 Subject: [PATCH] Fix todo!() errors in legacy client (#28) Replace the todo!() with relevant errors from hyper::Error --- src/client/legacy.rs | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/client/legacy.rs b/src/client/legacy.rs index d225a9a..a1edd59 100644 --- a/src/client/legacy.rs +++ b/src/client/legacy.rs @@ -58,6 +58,7 @@ pub struct Error { #[derive(Debug)] enum ErrorKind { Canceled, + ChannelClosed, Connect, UserUnsupportedRequestMethod, UserUnsupportedVersion, @@ -686,7 +687,7 @@ impl PoolClient { ) -> Poll> { match self.tx { #[cfg(feature = "http1")] - PoolTx::Http1(ref mut tx) => tx.poll_ready(cx).map_err(|_| todo!()), + PoolTx::Http1(ref mut tx) => tx.poll_ready(cx).map_err(Error::closed), #[cfg(feature = "http2")] PoolTx::Http2(_) => Poll::Ready(Ok(())), } @@ -739,7 +740,7 @@ impl PoolClient { #[cfg(feature = "http2")] PoolTx::Http2(ref mut tx) => Either::Right(tx.send_request(req)), } - .map_err(|_| todo!()); + .map_err(Error::tx); #[cfg(feature = "http1")] #[cfg(not(feature = "http2"))] @@ -747,7 +748,7 @@ impl PoolClient { #[cfg(feature = "http1")] PoolTx::Http1(ref mut tx) => tx.send_request(req), } - .map_err(|_| todo!()); + .map_err(Error::tx); #[cfg(not(feature = "http1"))] #[cfg(feature = "http2")] @@ -755,7 +756,7 @@ impl PoolClient { #[cfg(feature = "http2")] PoolTx::Http2(ref mut tx) => tx.send_request(req), } - .map_err(|_| todo!()); + .map_err(Error::tx); } /* //TODO: can we re-introduce this somehow? Or must people use tower::retry? @@ -1456,4 +1457,8 @@ impl Error { fn tx(src: hyper::Error) -> Self { e!(SendRequest, src) } + + fn closed(src: hyper::Error) -> Self { + e!(ChannelClosed, src) + } }