move changing permission before raising exception