Jul 16, 2023
But this code makes your program worse, not better.
In the original case, your program crashes, and you know there was a problem.
In the new code, you print some log message, but people rarely read those, and continue, even though `result` is not assigned.
Somewhere later it will crash, or do the wrong thing secretly.
in real production code, there are a large number of exceptions thrown, but a tiny number of places they are actually caught, usually near the top.
Never catch an exception unless you can do the right thing! And nearly always, the only place you can do the right thing is near the top of your code.