So it is said to catch only exceptions which you cannot predict or are exceptional.
So for example, IOExceptions instead of FileNotFoundException (As this single case can be handled with a simple file check ot avoid using exceptions as flow control).
This is my understanding of the topic, correct me if I am wrong.
However, this raises the question….why are exceptions like FileNotFoundException available?
Thanks
You should catch exceptions that you can handle. Your first sentence is a little off and might be what is causing your confusion.
This should read
Thus, if you can handle a FileNotFoundException, then you should catch it. There are a slew of exceptions that extend IOException and, surely, you cannot (would not want to?) handle all of them.