I'm trying to figure out exactly how the catch block flow progresses. In this scenario I want to handle the NamingException and InvalidSearchControlsException (which is a subclass of invalid search controls exception) differently. Therefore, I know that I would put the stricter, subclass exception first. However, my question is, if I then throw the subclass exception in the catch block which catches it, will the next catch block for the higher level exception then catch that exception I just threw?
Any Help Greatly Appreciated,
posted 11 years ago
The best way to test this is to write a small program with some SOP's (System.out.println()). However, to answer your question, afaik the "next catch block" will not catch the exception. You can either wrap the whole thing in another try...catch statement or declare that the method throws the exception.