▲ | ninkendo 4 days ago | ||||||||||||||||||||||
Except the java/python style with unchecked exceptions means an exception can happen at any time, there's no way to know in advance. This is what Rust is trying to avoid with the errors-as-values approach. It has its drawbacks, yes, but I'd never go back to the wild-west YOLO approach of unchecked exceptions, personally. | |||||||||||||||||||||||
▲ | zaphar 4 days ago | parent [-] | ||||||||||||||||||||||
To be fair, Rust could have done CheckedExceptions like Java has but no one uses. The problematic version is the RuntimeException. I think the real problem was that when Rust conceived of Result they didn't constrain the problem to just error handling and made it a little bit too much "anything goes". Which means that trying to shoehorn backtraces in after the fact with `?` and `try_into` is now hard. There could have been a world where `Result::Err` was actually a wrapper type that specified an optional source error for backtracing and the generic type was embedded in that instead. It would have been less flexible but it would have made proper backtraces more tractable. | |||||||||||||||||||||||
|