| 8 | |
| 9 | #[track_caller] |
| 10 | fn into_report(self) -> Result<T, Report<EyreReport>> { |
| 11 | match self { |
| 12 | Ok(value) => Ok(value), |
| 13 | Err(eyre) => { |
| 14 | let sources = eyre |
| 15 | .chain() |
| 16 | .skip(1) |
| 17 | .map(alloc::string::ToString::to_string) |
| 18 | .collect::<alloc::vec::Vec<_>>(); |
| 19 | |
| 20 | #[cfg_attr(not(feature = "std"), allow(unused_mut))] |
| 21 | let mut report: Report<EyreReport> = |
| 22 | Report::from_frame(Frame::from_eyre(eyre, Box::new([]))); |
| 23 | |
| 24 | for source in sources { |
| 25 | report = report.attach(source); |
| 26 | } |
| 27 | |
| 28 | Err(report) |
| 29 | } |
| 30 | } |
| 31 | } |
| 32 | } |