You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
AgencyClientError::from_msg(AgencyClientErrorKind::PostMessageFailed,format!("Could not connect {:?}", err))
55
+
AgencyClientError::from_msg(AgencyClientErrorKind::PostMessageFailed,format!("HTTP Client could not connect with {}, err: {}",url,err.to_string()))
57
56
})?;
58
57
59
-
if !response.status().is_success(){
60
-
match response.text().await{
61
-
Ok(content) => {
62
-
Err(AgencyClientError::from_msg(AgencyClientErrorKind::PostMessageFailed,format!("Agency responded with error. Details: {}", content)))
63
-
}
64
-
Err(_) => {
65
-
Err(AgencyClientError::from_msg(AgencyClientErrorKind::PostMessageFailed,format!("Agency response could not be read.")))
58
+
let content_length = response.content_length();
59
+
let response_status = response.status();
60
+
match response.text().await{
61
+
Ok(payload) => {
62
+
if response_status.is_success(){
63
+
Ok(payload.into_bytes())
64
+
}else{
65
+
Err(AgencyClientError::from_msg(AgencyClientErrorKind::PostMessageFailed,format!("POST {} failed due to non-success HTTP status: {}, response body: {}", url, response_status.to_string(), payload)))
66
66
}
67
67
}
68
-
}else{
69
-
Ok(response.text().await
70
-
.or(Err(AgencyClientError::from_msg(AgencyClientErrorKind::PostMessageFailed,"could not read response")))?.into())
68
+
Err(error) =>{
69
+
Err(AgencyClientError::from_msg(AgencyClientErrorKind::PostMessageFailed,format!("POST {} failed because response could not be decoded as utf-8, HTTP status: {}, content-length header: {:?}, error: {:?}", url, response_status.to_string(), content_length, error)))
0 commit comments