Improved exception thrown on invalid state