News for hackers. Stuff that matters.
Re:Why Checked Exceptions Failed by breadwinner on Saturday July 15, 2023 @09:30AM (#36736566)
When you catch the root Exception class in C# you end up catching IndexOutOfRangeException as well. You should let the program crash instead because this happened due to a bug in your program. Continuing as if nothing happened is unsafe.

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.

Re:Why Checked Exceptions Failed by Kwpolska on Saturday July 15, 2023 @09:33AM (#36736594)
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.
Re:Why Checked Exceptions Failed by wredue on Saturday July 15, 2023 @11:58AM (#36738025)
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