Re:Rust: Enums to Wrap Multiple Errors
by onei on Friday October 08, 2021 @02:22PM
(#28802392)
I really like the thiserror crate for cutting down boilerplate and you can add annotations to automatically implement From. However, if you want to handle errors with more granularity, e.g. IO errors as noted elsewhere in the discussion, then you'll need to implement From yourself.
And as others noted, .map_err(...) is slightly better than .or(...) for wrapping errors.
And as others noted, .map_err(...) is slightly better than .or(...) for wrapping errors.