← Back to context

Comment by Celeo

5 years ago

There are many ways to do it, like you said. Over time, the most popular options have shifted as new support from the standard library arrived. How you handle the errors can boil down to whether or not you really care about what kind of error it is, or just if an error occurred.

Two popular crates for handing these situations are thiserror [1] and anyhow [2], for handling errors by type and handling all errors, respectively.

There are additional ways, like just returning a Box wrapper around the stdlib error type [3], or just unwrapping everything. It depends on what your program needs.

[1] https://crates.io/crates/thiserror

[2] https://crates.io/crates/anyhow

[3] https://play.rust-lang.org/?version=stable&mode=debug&editio...