- let mut response = self.client.post::<JsonResponse>(&uri, &host, &self.basic_auth, content)
- .await?.0;
+ let mut response = match self.client.lock().await.post::<JsonResponse>(&uri, &host, &self.basic_auth, content).await {
+ Ok(JsonResponse(response)) => response,
+ Err(e) if e.kind() == std::io::ErrorKind::Other => {
+ match e.get_ref().unwrap().downcast_ref::<HttpError>() {
+ Some(http_error) => match JsonResponse::try_from(http_error.contents.clone()) {
+ Ok(JsonResponse(response)) => response,
+ Err(_) => Err(e)?,
+ },
+ None => Err(e)?,
+ }
+ },
+ Err(e) => Err(e)?,
+ };
+