client: use correct error for protocol errors
The 'Anyhow' error is not useful and meant for throw-away errors which cannot be dealt with anyway, and we'd like to be able to tell apart network problems from actual HTTP responses, so that we can potentially try a different node in a cluster connection. Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
This commit is contained in:
parent
c01318d966
commit
96e76d7f72
@ -223,7 +223,10 @@ impl Client {
|
||||
}
|
||||
.map_err(|err| Error::internal("failed to build request", err))?;
|
||||
|
||||
let response = client.request(request).await.map_err(Error::Anyhow)?;
|
||||
let response = client
|
||||
.request(request)
|
||||
.await
|
||||
.map_err(|err| Error::Client(err.into()))?;
|
||||
|
||||
if response.status() == StatusCode::UNAUTHORIZED {
|
||||
return Err(Error::Unauthorized);
|
||||
@ -318,7 +321,11 @@ impl Client {
|
||||
.body(request.body.into())
|
||||
.map_err(|err| Error::internal("error building login http request", err))?;
|
||||
|
||||
let api_response = self.client.request(request).await.map_err(Error::Anyhow)?;
|
||||
let api_response = self
|
||||
.client
|
||||
.request(request)
|
||||
.await
|
||||
.map_err(|err| Error::Client(err.into()))?;
|
||||
if !api_response.status().is_success() {
|
||||
return Err(Error::api(api_response.status(), "authentication failed"));
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user