Yes: whenever you can and want to restore them.
Many common exceptions inherit from RuntimeException
, and each may or may not be RuntimeException
depending on the specific circumstances. The RuntimeException
class RuntimeException
does not mean that the exception should or should not be caught.
For example, you might have a library method that throws an IllegalArgumentException
on specific inputs. If this applies to your program, you can catch this exception and somehow restore it, for example, by trying another input or explaining to the user why the operation cannot continue.
source share