In practice you can move the displayResult(x / 0) outside the try catch. It’s hard to think of a counterexample that comes up in practice.
There might be something to this idea, because I’ve often been in situations where a try catch catches an error that originates a dozen frames down the call stack, which is sometimes (but not always) unrelated to the original point of the try catch block. People try and deal with this by adding more try catches around the code deeper in the call stack, but maybe there’s a better way.
There might be something to this idea, because I’ve often been in situations where a try catch catches an error that originates a dozen frames down the call stack, which is sometimes (but not always) unrelated to the original point of the try catch block. People try and deal with this by adding more try catches around the code deeper in the call stack, but maybe there’s a better way.