import traceback


def _FormatException(exc):
  """Format an Exception the way it would be in a traceback.

  >>> err = ValueError('bad data')
  >>> _FormatException(err)
  'ValueError: bad data\n'
  """
  return ''.join(traceback.format_exception_only(type(exc), exc))