3 ms·
One pattern is to use your own crate-level Error type and then Result::map_err to bubble up other error types into your own thing. Example: https://play.rust-l
by unlinked_dll 7y ago
One pattern is to use your own crate-level Error type and then Result::map_err to bubble up other error types into your own thing. Example:
https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=48252c0056e0a13829bb5d24171687ed https://play.rust-lang.org/?version=stable&mode=debug&editio...
This makes error handling a little more verbose but you can use some quick and dirty macros for that.
- shepmaster 7y ago> but you can use some quick and dirty macros for that. That is the point of most of the libraries described in the article — to prevent having to recreate this particular wheel each time you need it. Do all Rust programs/libraries need one of the libraries? Not at all, but I find that using one that has some nice bells and whistles will encourage the programmer to improve the errors and their messages.