1)
1 - Only handle exceptions that you can actually do something about, and
2 - You can't do anything about the vast majority of exceptions
a) I assume that “By not handling an exception”
the text is suggesting that we should let the exception bubble up the stack, where runtime will abort our application?!
b) But why is letting the runtime abort the exception preferred over catching an exception, logging it and then informing the user of failure? Only difference between the two is that in the latter case application isn’t aborted
For example, if database goes down, why should the whole program crash ( due to not handling an exception ), if we can instead catch the exception, log it and notify user of failure and that way we can keep the program up and running
2) If you know that exception potentially raised by some block of code can’t be handled, should you include this code inside a try-finally
block or is it better to leave it outside any try-finally
blocks?
Thank you