err-as-you-go crate - anyhow meets thiserror
I've just published a macro I'm particularly proud of, which generates error variants for you as you write code.
#[err_as_you_go]
pub fn foo() -> Result<(), FooError> {
some_file_io().map(|e|
err!(FileIoFailed(std::io::Error = e)) // here
)?;
if some_condition() {
return Err(err!(ConditionFailed)); // and here
}
if count() > 1 {
return Err(err!(CountTooBig {
count: usize = count(), // also here
}));
}
Ok(())
}
The macro will generate a \pub enum FooError\\ with the requested variants.
Check out the docs for how you could integrate this with thiserror to easy-to-write, but application-friendly error handling :).
\- https://docs.rs/err-as-you-go