code: def testRewritingExporterHandlesError(self, base_exporter_mock):
      base_exporter_mock.side_effect = _export_fn
  
      tr = self._TestRewriter(True)
      r_e = converters.RewritingExporter(self._base_exporter, tr)
      with self.assertRaisesRegex(ValueError, ".*rewrite-error"):
          r_e.export(
              self._estimator,
              self._export_path,
              self._checkpoint_path,
              self._eval_result,
              self._is_the_final_export,
          )
      base_exporter_mock.assert_called_once_with(
          self._estimator,
          self._export_path,
          self._checkpoint_path,
          self._eval_result,
          self._is_the_final_export,
      )
      self.assertTrue(tr.rewrite_called)
  
file_path: tfx/tfx/components/trainer/rewriting/converters_test.py
imports: import os
  import tempfile
  from absl.testing.absltest import mock
  import tensorflow
  from tensorflow import estimator
  from tfx.components.trainer.rewriting import converters
  from tfx.components.trainer.rewriting import rewriter
  from tfx.dsl.io import fileio
label_desc: Use image node_id 4 for calling the RewritingExporterTest obj's underlying member method code with example usage: obj.testRewritingExporterHandlesError(base_exporter_mock) without return types