ion-elgreco commented on issue #6377:
URL: https://github.com/apache/arrow-rs/issues/6377#issuecomment-2726499875
I ended up with a slightly modified version of @crepererum to get this:
```
OSError: Generic S3 error
↳ Error after 10 retries in 2.148052083s, max_retries:10,
retry_timeout:180s, source:error sending request for url
(https://127.0.0.1/hello/world/_delta_log/_last_checkpoint)
↳ client error (Connect)
↳ tcp connect error
↳ Connection refused (os error 61)
```
```
#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash, Default)]
pub struct DisplaySourceChain<T> {
err: T,
error_name: String,
}
impl<T: Error + 'static> Display for DisplaySourceChain<T> {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
// walk the source chain and collect error messages
let mut err_msgs = Vec::new();
let mut current_err = Some(&self.err as &(dyn Error + 'static));
while let Some(err) = current_err {
let err_msg = err.to_string();
err_msgs.push(err_msg);
current_err = err.source();
}
// produce output message parts from source error messages
// message parts are delimited by the substring ": "
let mut out_parts = Vec::with_capacity(err_msgs.capacity());
for err_msg in &err_msgs {
// not very clean but std lib doesn't easily support splitting
on two substrings
for err_part in err_msg.split(": ").flat_map(|s|
s.split("\ncaused by\n")) {
if !err_part.is_empty()
&& !out_parts.contains(&err_part)
&& !out_parts.iter().map(|p|
p.contains(&err_part)).any(|v| v)
{
out_parts.push(err_part);
}
}
}
for (i, part) in out_parts.iter().enumerate() {
if i == 0 {
write!(f, "{}\n", part)?;
} else {
write!(
f,
"{}\x1b[31m{}\x1b[0m {}\n",
" ".repeat(self.error_name.len() + ": ".len() + i),
"↳",
part
)?;
}
}
Ok(())
}
}
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]