3 ms·
There’s much not to like about C++ exceptions, I get it, but as a C++ programmer the proliferation of error types in Rust rubs me the wrong way. I like that C++
by jonstewart 1y ago
There’s much not to like about C++ exceptions, I get it, but as a C++ programmer the proliferation of error types in Rust rubs me the wrong way. I like that C++ defines a hierarchy of exceptions, like Python, and you are free to reuse them. I do not want to go to the hassle of defining some new error types everywhere, I just want to use equivalents to runtime_error or logic_error. It feels like Rust is multiplying unnecessarily.
- pjmlp 1y agoIt isn't even the proliferation per se, rather that integration them requires macros, boilerplate code and reaching out to external crates, for what should be builtin.
- Expurple 1y agoThe boilerplate is more meaningful than it seems: https://home.expurple.me/posts/why-use-structured-errors-in-rust-applications/#pattern-matching-isnt-the-only-reason-to-use-structured-errors https://home.expurple.me/posts/why-use-structured-errors-in-...
- Expurple 1y ago> I do not want to go to the hassle of defining some new error types everywhere, I just want to use equivalents to runtime_error or logic_error. You can use anyhow::Error everywhere. If you need to "catch" a specific wrapped error, you can manually document it on the "throwing" method and downcast where you "catch". It's very similar to exceptions (checked-but-unspecific `throws Exception` in Java), but better, because Result and ? are explicit.