3 ms·
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 t
by Kwpolska 3y ago
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.
- breadwinner 3y agoIf 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.
- wredue 3y agoThe “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