Recursively concatenate `e.source()`, separated by ": ".
(e: &impl std::error::Error)
| 75 | |
| 76 | /// Recursively concatenate `e.source()`, separated by ": ". |
| 77 | pub(crate) fn source_chain(e: &impl std::error::Error) -> String { |
| 78 | let mut s = String::new(); |
| 79 | let mut source = e.source(); |
| 80 | while let Some(cause) = source { |
| 81 | s.push(':'); |
| 82 | s.push(' '); |
| 83 | s.push_str(&cause.to_string()); |
| 84 | source = cause.source() |
| 85 | } |
| 86 | |
| 87 | s |
| 88 | } |