Re: Where can I find a list of Exceptions that I am allowed to throw?
"H." <hbe123@gmail.com> wrote in message
news:1175456788.149954.213820@y80g2000hsf.googlegroups.com...
For example, IllegalArgumentException, etc.
I am relatively new to Java...I browsed through the docs, but couldn't
quite find what I'm looking for, which is, simply put, the built-in
Java exceptions that I, as a programmer, am allowed to throw...
You can throw anything you want, as long as it extends java.lang.Throwable
(http://java.sun.com/javase/6/docs/api/java/lang/Throwable.html). You can
create your own. Normally, people extend java.lang.Exception, and often they
extend standard exceptions that have the semantics nearest to their error
situation (e.g., java.io.IOException). It would be practically impossible to
create a list that enumerates every Java exception ever created.
java.lang.Exception
(http://java.sun.com/javase/6/docs/api/java/lang/Exception.html) lists most
of the known descendants of Exceptions defined in the core Java libraries.
java.lang.RuntimeException
(http://java.sun.com/javase/6/docs/api/java/lang/RuntimeException.html)
lists most of the known unchecked exceptions defined in the core Java
libraries.
Finally, JavaDoc, by default, generates a list of exceptions defined for
every package. It shows up near the bottom of the lower left pane when
viewing JavaDocs in frames mode.