Skip to content

Commit 78b4aaf

Browse files
authored
[SDS-1412] Richer error string on AWS Failure (#263)
1 parent 4d0ef66 commit 78b4aaf

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

sds/src/match_validation/aws_validator.rs

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
use std::error::Error as StdError;
12
use std::fmt;
23

34
use super::{
@@ -164,9 +165,19 @@ impl MatchValidator for AwsValidator {
164165
match res {
165166
Ok(val) => handle_reqwest_response(match_status, &val),
166167
Err(err) => {
167-
*match_status = MatchStatus::Error(fmt::format(format_args!(
168-
"Error making HTTP request: {err}"
169-
)));
168+
let mut msg = format!("Error making HTTP request: {err}");
169+
if err.is_timeout() {
170+
msg.push_str(": timeout");
171+
} else if err.is_connect() {
172+
msg.push_str(": connect error");
173+
}
174+
if let Some(status) = err.status() {
175+
msg.push_str(format!(": status {}", status.as_u16()).as_str());
176+
}
177+
if let Some(source) = StdError::source(&err) {
178+
msg.push_str(format!(": {}", source).as_str());
179+
}
180+
*match_status = MatchStatus::Error(msg);
170181
}
171182
};
172183
});

0 commit comments

Comments
 (0)