0

This question may sound stupid, but why do we have to throw several exceptions while we can just throw Throwable or Exception?

1 Answers1

0

As far as I know, this is similar to why, in a try-catch block, programmers like to list out the various exceptions in individual catch clauses rather than just catching Exception overall. This is mostly a readability and documentation best-practice. Anyone else reading your program will know explicitly what errors are being tracked for or thrown. If I'm reading dense code from someone else that is dealing with audio input-output, for example, it is much more informative to me if I know that I can expect a LineUnsupportedException rather than just a generic exception.