I have been in both situations:
In both cases the project s
My own rule of thumb:
I never throw Exception, except in unit tests when what you throw is irrelevant and theres no reason to spend any extra time on it.
I create my own custom exception type for errors occuring in my custom business logic. This exception type is used as much as possible for recasting other exceptions, except in cases where it makes sense for the client to have visibility into what actually occurred.
Avoid creating your own exception. Use the below ones that are already there.
IllegalStateException
UnsupportedOperationException
IllegalArgumentException
NoSuchElementException
NullPointerException
Throw unchecked exceptions.
public void validate(MyObject myObjectInstance) {
if (!myObjectList.contains(myObjectInstance))
throw new NoSuchElementException("object not present in list");
}