I have read few articles on google but I am still confused when to use what. I have come across checked and unchecked exceptions. I have one exception which I need to define. Let say, when xyz is null, I need to throw the inconsistentcyException which I will catch in the same file and that catch() block will throw one exception which extends runtime exception. This exception which I am defining newly would be used in this file only.
try{
if(xyz == null) {
throw new InconsistentException();
}
catch(InconsistentException e)
throw new AlreadyExisitingExceptionExtendingRuntimeException();
}
}
I need to define the class having Inconsistent Exception. This snippet is written in execute() function and call() function is calling it which is catching the AlreadyExisitingExceptionExtendingRuntimeException(). I don't know which exception to use(runtime or exception). Please explain. I read the SO links but confused. Can you please explain with an example? :) Thanks in advance.