There are two types of Exceptions in Java: Checked Exceptions and Unchecked Exceptions. Checked exception has to be caught or declared to be thrown (like MalfomedURLException
) but catching Unchecked exceptions (like IllegalArgumentException
) is not mandatory and you can let the caller catch them (or throw them up to its caller).
For more information, take a look at this post:
Java: Checked vs Unchecked Exceptions Explanation
If you inherit your custom exception class from RuntimeException
or any exception class inherited from it, then catching your exception will not be mandatory.