Catch the root Exception class, show an error, but let the user continue working if possible. For a web app, there already is a catch-all exception handler at the request level that prevents the entire server from crashing. For other environments, having a catch-all handler at some top-level interaction point (i.e. on buttons or menu items) would be a good choice too.
Re:Why Checked Exceptions Failed
by breadwinner on Saturday July 15, 2023 @09:41AM
(#36736662)
If the exception that was thrown (by a method you called) is in fact a condition your code can recover from, then the functionality of your code was needlessly aborted.
The “if it’s possible” is a major part of the reason to not catch the root exception.
Catching typed exceptions give you much more easily parsable details about whether or not “it’s possible” to recover.
It’s bad practice to catch the root exception. More often than not, it points to an inexperienced developer
Re:Why Checked Exceptions Failed
by beached_whale on Saturday July 15, 2023 @09:32AM
(#36736591)
I meant at the higher layers, minus some potential cleaning, a lot of library code is exception neutral and shouldn’t care
Another issue is that you are not allowing higher layers see the exception, even though they may have logic for recovering from the exception. To see the exception they have to now fix your code by removing the catch-all.