3 ms·
Look at the failure crate. For lots of errors, just treating them as a generic failure makes code a lot better.
by richardwhiuk 7y ago
Look at the failure crate.
For lots of errors, just treating them as a generic failure makes code a lot better.
- jedisct1 7y agoWhich is supposed to be replaced by https://github.com/withoutboats/fehler https://github.com/withoutboats/fehler
- munmaek 7y agoFehler is highly opinionated and I'm not sure it's worth it. IIRC the author posted on the /r/rust subreddit and was unable to take criticism at all. I don't like having to put decorators on functions and manually throw!()'ing. I would rather be explicit about returning Ok(T) or Err(E).
- munmaek 7y agoI did mention Failure/Snafu, but there are two problems with it: 1) The state of "how best to handle errors" keeps on changing. It was error_chain, then err-derive, then Failure, now Fehler or Snafu.. I would like to see this space calm down a bit. 2) Failure/Snafu require additional dependencies. For minimal libraries it's really not necessary to pull in so much when a a little boilerplate suffices. [0] [0]: https://git.sr.ht/~andrewzah/hangeul-rs/tree/master/src/errors.rs https://git.sr.ht/~andrewzah/hangeul-rs/tree/master/src/erro...