In: Computer Science
Describe why overly broad exceptions are a problem. In particular, what should you do if you are worried you might catch an exception you cannot directly deal with?
Multiple catch blocks can get repetitive, but condensing catch blocks by catching a high-level class such as Exception can obscure exceptions that deserve special treatment .
Catching an overly broad exception essentially defeats the purpose of Java's typed exceptions , and can become particularly dangerous if the program grows and begins to throw new types of exceptions.The new exception types will not receive any attention.