I haven't touched Java in 10 years, but didn't it have explicit propagation with `throws` statement for this exact purpose?
I haven't touched Java in 10 years, but didn't it have explicit propagation with `throws` statement for this exact purpose?
If the exception is not a RuntimeException and not declared in the throws clause, then the compiler will error out, but in other cases the code will compile.
In Rust, you need to use the "?" operator when you call an exception-throwing function to propagate the exception, and if you don't you will get a Result, and a warning if you don't use it (i.e. not using "?" in Rust is like using Try in Scala).
If Rust code has no "?" or "return", then no exceptions will be thrown and the code will fully execute, except for aborts and panics which are guaranteed to make all visible memory inaccessible, so you will never see a partial modification of an object due to an unexpected exception being thrown.
Similarly, all unchecked errors and exceptions mean that you never know. So you have to treat critical sections of code as areas where resources need to be cleaned up by using try and finally blocks.