Changed return ValueError to raise ValueError in substitutor.