be thrown, the circumstances under which it will be thrown, and what the caller might to do
avoid the exception or deal with it if it is thrown. It isn't the perfect solution, but it is the best
that is open to you.
[ 10 ] Actually, there are two other possible reasons that a programmer might not use exceptions. There are
applications that simply can't tolerate exceptions, such as industrial control applications that deal with
any failure at the very highest level of the code. There are also libraries where you can assume those
who are calling the library will take care of all exceptional conditions. The first of these is rare, and the
second requires a level of trust that also makes it uncommon.
[ 11 ] Which preexisting exception you should throw can also be a point of contention. In this example,
there are some who would prefer throwing the already-defined NullPointerException rather than
an IllegalArgumentException . Since both are RuntimeExceptions , the points made here still hold.
Which exception you decide to throw may be a design decision best made in consultation with your
group and in a manner that is consistent through the whole group.