Returning anyhow::Errors, as well as any other opaque error struct, makes it hard to consume a library. Beyond having no recourse but to pass the failure up, it creates issues integrating with other error crates, such as eyre or miette.
anyhow is meant to be used by applications, not libraries, which is why the same author as anyhow made thiserror. That said, I would recommend using snafu, which can provide the functionalities of both anyhow and thiserror. It's still prudent to create a custom error type in the fashion of thiserror, but snafu provides comparable tooling.
Returning
anyhow::Errors, as well as any other opaque error struct, makes it hard to consume a library. Beyond having no recourse but to pass the failure up, it creates issues integrating with other error crates, such aseyreormiette.anyhowis meant to be used by applications, not libraries, which is why the same author asanyhowmadethiserror. That said, I would recommend usingsnafu, which can provide the functionalities of bothanyhowandthiserror. It's still prudent to create a custom error type in the fashion ofthiserror, butsnafuprovides comparable tooling.