4 ms·
The difference between just "?" and "?" + <good error message> is much greater than the difference between "if err != nil { return err }" and "if err != nil { r
by Mawr 1y ago
The difference between just "?" and "?" + <good error message> is much greater than the difference between "if err != nil { return err }" and "if err != nil { return fmt.Errorf("<good error message") }".
Part of it is the syntactical easiness of "?", how can any other solution compete with the ease of typing a single character?
But mostly, it's that "fmt.Errorf" is built-in and widely used, as opposed to whatever library you need to go out of your way to choose to be able to easily annotate errors in Rust.
- tcfhgj 1y agoBut to be able to actually use just "?" you need a specific library as well. So according to your wording you go out of your way to to be able to just use "?".