3 ms·
> It's a lot of mental overhead having to constantly think about all the different types of errors from different crates that could be returned and how to handl
by FridgeSeal 5y ago
> It's a lot of mental overhead having to constantly think about all the different types of errors from different crates that could be returned and how to handle them at the caller.
If you care about handling errors robustly, you have to care about this stuff at some point, and if you don’t, just use something like Anyhow and never worry again.
When I write Rust stuff, I usually start with Anyhow::Result everywhere, then once everything’s built and working and/or we want more finesse over our error handling I progressively swap to ThisError/etc, I find it’s the best mix of utility and ease of writing.
> I've noticed a lot of Rust discussion is on how to write the code or make the compiler happy which is quite telling
I suspect this is because a lot of people come from other languages, and try to bring the prior languages quirks and idioms with them, quickly discover the stricter compiler flat out doesn’t permit some of them (unlike other languages), then they figure out the idiomatic/closer way and write up their thoughts on the process.
- rustnote 5y agoError handling is one area I way prefer in Rust. It's trivial but having a single line "expect" to throw on some additional text to an error if it doesn't need anything else is really nice. In Go even something really simple might have a bunch of three line error checks everywhere and it just doesn't feel nice to me.