code: def test_scm_context_clears_ignores_on_error(scm_context):
      class CustomException(Exception):
          pass
  
      with pytest.raises(CustomException), scm_context():  # noqa: PT012
          scm_context.ignore("foo")
          assert scm_context.ignored_paths == ["foo"]
          raise CustomException
  
      scm_context.scm.ignore_remove.assert_called_once_with("foo")
      assert scm_context.files_to_track == {".gitignore"}
      assert not scm_context.ignored_paths
  
file_path: dvc/tests/unit/repo/test_scm_context.py
imports: import re
  import pytest
  from dvc.repo.scm_context import SCMContext
  from dvc.scm import Git, NoSCM
label_desc: Use image node_id 9 for calling a global function with example usage: test_scm_context_clears_ignores_on_error(scm_context) without return types