Use Foreman::Exception here. Also there's a typo, it whould be "... is not a valid hostgroup... "