Fixing #2913: use IllegalStateException instead.