What exception to throw when a property or a method being accessed is temporarily unavailable (as it makes no sense in the current state of the object)?
Following is a semi-illustrative example coming into my mind, don’t take it too serious, try to consider the question itself if you get it.
A fraction class having numerator and denominator read-and-write properties and quotient read-only property. If denominator does not equal 0 then quotient is to return numerator/denominator else it is to throw an exception saying that the property value is not defined/available for the current state of the object (please don’t offer ArithmeticException or DivideByZeroException, the question is not about arithmetics, it is closer to the finite state machines subject).
Another example can be an object of a class doing some complex calculations in a parallel thread and providing the result as a field – it can throw the exception if the calculations are not complete yet.
I am interested in answers for Java and .Net platforms.
java.lang.IllegalStateException