4 ms·
Rust has a system equivalent to checked exceptions. However Rust, unlike Java, has a great macro system and can thus easily generate higher level exceptions wr
by devit 6y ago
Rust has a system equivalent to checked exceptions.
However Rust, unlike Java, has a great macro system and can thus easily generate higher level exceptions wrapping the lower level ones.
- ragnese 6y agoI don't use any of the Rust error helpers. I don't mind a bit of boilerplate. I don't hate Java's checked exceptions. But I also actually craft my own Exception types when I write a Java package. I think that's the biggest mistake that devs make. In Rust you have to combine errors into composite error types. In Java you should do that.
- masklinn 6y agoRust's macro system is not what makes its "system equivalent to checked exceptions" bearable. That the language provides tools to operate on both results themselves and their content (in part because results are reified and thus normal values of the language, and in part because specific tooling like `?`) is what does that. Also that there is no issue of misclassification as in Java, because everything is a result and that's that.