4 ms·
wrapping the error at the source is sensible, but if you need to pass the error five levels up before reaching the function that's actually responsible for hand
by jesseduffield 5y ago
wrapping the error at the source is sensible, but if you need to pass the error five levels up before reaching the function that's actually responsible for handling it (e.g. retrying after a period), I find the wrapping becomes superfluous and further obscures the intention of the function. Rust's `?` operator works well here.
- xh-dude 5y agoThere is no categorical presumption in Go that an error invalidates what would be boxed in a Result or Option. I do think that what seems obviously true and categorical in the absence of concurrency is quite a bit more subtle when concurrent. It’s obvious when rewriting the kind of chains where ‘?’ makes perfect sense from sequential to concurrent invocation. By no means do I think Go is perfect or can’t learn from Rust but I do think it’s important to consider the tradeoffs against Go’s colorless concurrency - it’s a very compelling affordance. Like garbage collection it’s easy to show the pros and cons in a codebase the size of a demonstration but at scale it’s a decision with pros and cons.