Instead of throwing new Exception(\"Some message\", maybeSomeCause)
, which means that all callers of my method will need to catch Exception (which can include Runti
If users of your code might need to do different things on two different exceptions, then those should be distinct exception types. That said, the JDK exceptions cover most of the "programmer error" exceptions -- if an IllegalArgumentException
is getting thrown, for example, that indicates a programming mistake, not something that should be handled at runtime.