About java.lang.IllegalStateException, a general-purpose exception defined in the Java API.
A java.lang.IllegalStateException is a Java RuntimeException
that:
Signals that a method has been invoked at an illegal or inappropriate time. In other words, the Java environment or Java application is not in an appropriate state for the requested operation.
In particular, this exception is often used when the object the method is invoked on is currently in a state where this method should not be called. For instance, Effective Java writes (Item 60, page 248):
Another commonly reused exception is IllegalStateException. This is generally the exception to throw if the invocation is illegal because of the state of the receiving object. For example, this would be the exception to throw if the caller attempted to use some object before it had been properly initialized.