cameleon
cameleon copied to clipboard
Stop using `anyhow::Error`?
I see that cameleon
uses anyhow::Error
, but very lightly: https://github.com/search?q=repo%3Acameleon-rs%2Fcameleon%20anyhow&type=code (only for 2 Io
error variants).
Anyhow specifically isn't designed for library errors, so it would be best to replace these with something different, perhaps custom thiserror
-derived errors (which has a benefit of not ending up in the crate signature).
A nice side-effect would be removing the dependency (for people that don't use anyhow
in their apps).
Or @Y-Nak do you recall having a specific reason to use anyhow
? CC @bschwind @mbernat.
- I believe the guideline is to use bespoke errors for libraries as much as possible;
thiserror
helps with this. - The other option is to use something like
Box<dyn std::error::Error>
. Not as nice but at least it's using a stable type. - The least appealing option is to use a library error (such as
anyhow
's) because these are not stable, so a semver hazard. Seeeyre
's rationale, it should apply verbatim toanyhow
as well.
I agree to remove anyhow
and use thiserror
instead. I don't remember why I decided to use anyhow
here. I probably intended to use it as a stopgap before elaborating error kinds, then forgot to fix it 😅