Provides a generic error collection around dynamic errors. Powered by anyhow.
This is helpful because we often don't want to bail at the first error. For example, take a simple method:
fn setup() -> Result<()> {
lights()?;
camera()?;
action()?;
Ok(())
}We want the error to describe how setup failed, but we return at the very first instance of an error. We are loosing valuable information during runtime that could help debug a problem!
An Errors collection can help with this problem:
fn setup() -> Result<()> {
let mut errors = Errors::new();
errors.collect(lights());
errors.collect(camera());
errors.collect(action());
errors.as_result()
}While this is more verbose, we now get a complete error when we have multiple failure points:
2 errors:
1. Missing lightbulb
2. Camera needs film
For more examples see the docs for the Errors struct.