3 ms·
There are some crates that add a derive for errors, but most people tend to use error-chain or quick-error. Both give you the boilerplate pretty much for free,
by killercup 9y ago
There are some crates that add a derive for errors, but most people tend to use error-chain or quick-error. Both give you the boilerplate pretty much for free, with various other advantages. E.g., using error-chain, you can just write the above code as
error_chain! {
foreign_links {
Io(io::Error);
Parse(ParseIntError);
}
}
and it'll even generate an aliased `Result` type as well as fancy chaining support.
- Rusky 9y agoRight- error_chain is just a bit too much magic for me compared to what #[derive(From)] would do.