3 ms·
It's not subtle in that it's not opaque to the programmer that it's just a "regular" sum type It's not important in that it doesn't change what the programmer
by mike_hock 3y ago
It's not subtle in that it's not opaque to the programmer that it's just a "regular" sum type
It's not important in that it doesn't change what the programmer can do with it, it just changes the syntax used.
Return an error: return Err(...) vs. throw ...
Propagate error to caller: ? vs. nothing
Store/modify/nest/pass: Without try/catch/throw construct vs. WITH try/catch/throw construct.
The much more important difference is between bounded vs. unbounded error types. Rust falls in the former camp and inherits all the problems (and benefits) that come with it.
- pornel 3y agoI'm not sure what you mean by bounded. There's `dyn Error` that lets you unify all error types. You can also make functions generic over the error type. Places where people use precise concrete error types are not forced by the language, it's just the best practice for libraries.