3 ms·
You should try using `map_err` and the `?` operator, with your own error enum defined using the `failure_derive` crate, for example: foo().map_err(|e| MyEr
by smaddox 8y ago
You should try using `map_err` and the `?` operator, with your own error enum defined using the `failure_derive` crate, for example:
foo().map_err(|e| MyError::FooError(e))?
.bar().map_err(|e| MyError::BarError(e))?;
- dakom 8y agod'oh - you beat me to it ;)
- kouteiheika 8y agoA tip - you usually don't need lambdas in such cases; this should work: foo().map_err(MyError::FooError)? .bar().map_err(MyError::BarError)?;
- smaddox 8y agoOh, nice! I did not realize tuple constructors implemented `FnOnce`! Thanks for the tip!