It is not necessary to extend from exception but a good programing practice. If you look at the Exception hierarchy it has a parallel to Error which is child of throwable.
More generally in application you create your own exception hierarchies.
Edward Chen wrote:
We usually extend Exception instead of Throwable. Why? In what situations we extend Throwable.
Never extends throwable, extends Exception or an existing subclass of Exception as you want to add another kind of Exception not a kind of Throwable. You can extends RuntimeException if you need your exception to be unchecked.
As you can see the specs throwable has 2 child hierarchies namely error and exception. Error are "serious" errors that a program generally shouldn't expect to catch and recover from while Exceptions are errors that a program can reasonably recover from.
Hence we should try to use Exceptions in all our applications.