I want to ask if someone can help me that what is the best way for managing exception like if we add some user and want to throw for ex. UserNotExist should we extend with Exception or Runtime exception , does anyone have any material that can help me .
Asked
Active
Viewed 45 times
0
-
5Possible duplicate of [Java: checked vs unchecked exception explanation](http://stackoverflow.com/questions/6115896/java-checked-vs-unchecked-exception-explanation) – radoh Jan 04 '17 at 13:21
1 Answers
0
As exceptions inherited from Exception
class are checked exceptions, and exceptions inherited from RuntimeException
class are unchecked exceptions, your question may be viewed, as what kind of exceptions to use.
As recommended in Oracle official documentation:
If a client can reasonably be expected to recover from an exception, make it a checked exception.
If a client cannot do anything to recover from the exception, make it an unchecked exception.

DimaSan
- 12,264
- 11
- 65
- 75