Skip to content

Commit

Permalink
Fix todo!() errors in legacy client (#28)
Browse files Browse the repository at this point in the history
Replace the todo!() with relevant errors from hyper::Error
  • Loading branch information
film42 committed May 22, 2023
1 parent 6f96103 commit 4390d51
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions src/client/legacy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ pub struct Error {
#[derive(Debug)]
enum ErrorKind {
Canceled,
ChannelClosed,
Connect,
UserUnsupportedRequestMethod,
UserUnsupportedVersion,
Expand Down Expand Up @@ -686,7 +687,7 @@ impl<B> PoolClient<B> {
) -> Poll<Result<(), Error>> {
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(())),
}
Expand Down Expand Up @@ -739,23 +740,23 @@ impl<B: Body + 'static> PoolClient<B> {
#[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"))]
return match self.tx {
#[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")]
return match self.tx {
#[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?
Expand Down Expand Up @@ -1456,4 +1457,8 @@ impl Error {
fn tx(src: hyper::Error) -> Self {
e!(SendRequest, src)
}

fn closed(src: hyper::Error) -> Self {
e!(ChannelClosed, src)
}
}

0 comments on commit 4390d51

Please sign in to comment.