In some cases it might be useful to bundle several errors into one, displaying them all together. A few prior example are Python's PEP 654, Trio's MultiError (which inspired the former), and Haskell's Validate monad. Would something like that be possible and/or reasonable to add? Asking here rather than eyre because section is here, so it feels appropriate.
I can get a mediocre implementation by doing
use std::fmt::Write;
use color_eyre::{Section, SectionExt};
match errors.len() {
0 => Ok(result),
1 => Err(errors.pop().unwrap()),
_ => Err(eyre::eyre!("Multiple errors").section({
let mut s = String::new();
for e in errors {
write!(s, "{:?}", e).unwrap();
}
s.header("Errors:")
})),
}
, but the formatting is pretty bad and contains much duplication; in particular, trimming off the shared tail of the backtraces would make it much better.
In some cases it might be useful to bundle several errors into one, displaying them all together. A few prior example are Python's PEP 654, Trio's MultiError (which inspired the former), and Haskell's Validate monad. Would something like that be possible and/or reasonable to add? Asking here rather than
eyre
becausesection
is here, so it feels appropriate.I can get a mediocre implementation by doing
, but the formatting is pretty bad and contains much duplication; in particular, trimming off the shared tail of the backtraces would make it much better.