Lew wrote:
Other uses of exceptions tend to be an antipattern. Use of
conditional checks is usually better.
Mike Schilling wrote:
Unfortunately, exceptions that are expected (and thus caught and
ignored) abound in code that you can't do anything about, like the
JDK classes. Try running some Java program under a debugger that
breaks on all exceptions and you'll see what I mean.
There's one sensibility for application development, and another for
API development. The API part throws Exceptions, in part because an
API writer has to be sure to lock down future, unguessable (ab)uses
of the library. The application part "knows" its own logic, and
what
conditions cause an API call to throw an Exception, so it can and
should guard against those conditions /a priori/, not permitting the
Exception. Often, not always.
[... Much good discussion of the use of Exceptions clipped]