3 ms·
Catching exceptions caused by a bug has no sense in production code. For debugging purposes exceptions aren't necessary, a compiler can just insert asserts and
by Panzerschrek 1y ago
Catching exceptions caused by a bug has no sense in production code. For debugging purposes exceptions aren't necessary, a compiler can just insert asserts and call stack printing at the place where a bug was detected.
I agree that errors handling as it is implemented in Go is error-prone. Rust does this much better - values of a Result type shouldn't be discarded.
- xg15 1y ago> For debugging purposes exceptions aren't necessary, a compiler can just insert asserts and call stack printing at the place where a bug was detected. For that, you'd have to know the location in the first place, which you usually don't.
- samus 1y agoYou are not supposed to catch such exceptions in the first place, except at the very top level as a fallback to implement proper logging and to signal an unexpected internal error to the user. In Java, such exceptions are subclasses of RuntimeException. Just printing a warning is not always appropriate. The code would continue to work and produce invalid data and actions.