Add illegal-state utility function.