Skip to content

Commit

Permalink
Merge pull request #1006 from teozkr/chore/avoid-send-unwraps
Browse files Browse the repository at this point in the history
Prove that a few unwraps (expects) are impossible
  • Loading branch information
nightkr committed Sep 12, 2022
2 parents 79e4e09 + 65a0627 commit 15faafb
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions kube-client/src/client/mod.rs
Expand Up @@ -144,16 +144,13 @@ impl Client {
.call(request)
.await
.map_err(|err| {
if err.is::<Error>() {
// Error decorating request
*err.downcast::<Error>().expect("kube_client::Error")
} else if err.is::<hyper::Error>() {
// Error decorating request
err.downcast::<Error>()
.map(|e| *e)
// Error requesting
Error::HyperError(*err.downcast::<hyper::Error>().expect("hyper::Error"))
} else {
// Errors from other middlewares
Error::Service(err)
}
.or_else(|err| err.downcast::<hyper::Error>().map(|err| Error::HyperError(*err)))
// Error from another middleware
.unwrap_or_else(|err| Error::Service(err))
})?;
Ok(res)
}
Expand Down

0 comments on commit 15faafb

Please sign in to comment.